Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chakra-ui/color-mode

Package Overview
Dependencies
Maintainers
3
Versions
363
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/color-mode

React component and hooks for handling light and dark mode.

  • 0.0.0-dev-20220820185458
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
528K
decreased by-5.41%
Maintainers
3
Weekly downloads
 
Created

What is @chakra-ui/color-mode?

@chakra-ui/color-mode is a package that provides utilities for managing color modes (e.g., light and dark themes) in Chakra UI applications. It allows developers to easily toggle between different color modes and persist the user's preference.

What are @chakra-ui/color-mode's main functionalities?

Color Mode Provider

The Color Mode Provider is used to wrap your application and provide the color mode context to all components within the app.

import { ChakraProvider, ColorModeProvider } from '@chakra-ui/react';

function App() {
  return (
    <ChakraProvider>
      <ColorModeProvider>
        <YourComponent />
      </ColorModeProvider>
    </ChakraProvider>
  );
}

useColorMode Hook

The useColorMode hook allows you to access the current color mode and a function to toggle between light and dark modes.

import { useColorMode } from '@chakra-ui/react';

function ToggleButton() {
  const { colorMode, toggleColorMode } = useColorMode();
  return (
    <button onClick={toggleColorMode}>
      Toggle {colorMode === 'light' ? 'Dark' : 'Light'}
    </button>
  );
}

Color Mode Script

The Color Mode Script is used to ensure that the initial color mode is correctly set on the server-side and during hydration.

import { ColorModeScript } from '@chakra-ui/react';

function App() {
  return (
    <html>
      <head>
        <ColorModeScript />
      </head>
      <body>
        <YourComponent />
      </body>
    </html>
  );
}

Other packages similar to @chakra-ui/color-mode

Keywords

FAQs

Package last updated on 20 Aug 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc