New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@hrc/toggle-theme

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hrc/toggle-theme

Simple component for toggle between light and dark theme in your React app

latest
Source
npmnpm
Version
2.4.0
Version published
Maintainers
0
Created
Source

@hrc/toggle-theme

version npm bundle size npm downloads

Simple component for toggle between light and dark theme in your React app.

  • It saves the theme in localStorage with the key theme by default
  • If there is no theme in localStorage, the default is the user's preferred theme

Installation

npm install @hrc/toggle-theme

Usage

  • Use the component in your project:

    import { ThemeButton } from "@hrc/toggle-theme";
    import { Icon } from "@hrc/material-icons";
    
    const Light = () => {
      return (
        <>
          <Icon name="light_mode" size="large" color="warning" />
          <span>Light</span>
        </>
      );
    };
    
    const Dark = () => {
      return (
        <>
          <Icon name="dark_mode" size="large" color="info" />
          <span>Dark</span>
        </>
      );
    };
    
    export function PackageDemo() {
      return <ThemeButton lightElement={<Light />} darkElement={<Dark />} />;
    }
    
  • Add your styles:

    :root {
      --bg-color: #fff;
      --text-color: #17181c;
    }
    [data-theme="dark"] {
      --bg-color: #17181c;
      --text-color: #fff;
    }
    
    body {
      background-color: var(--bg-color);
      color: var(--text-color);
    }
    

Documentation

Keywords

react

FAQs

Package last updated on 14 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts