1.0.2 • Published 1 year ago

@alikia/dark-theme-hook v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Dark Theme Hook

Dark Theme Hook is a custom React hook that allows you to detect the user's preferred color scheme, specifically whether they have enabled dark mode. This hook listens for changes in the user's system preferences and updates accordingly.

Installation

You can install Dark Theme Hook using your preferred package manager:

npm install @alikia/dark-theme-hook
yarn add @alikia/dark-theme-hook
pnpm add @alikia/dark-theme-hook
bun add @alikia/dark-theme-hook

Usage

To use the Dark Theme Hook in your React application, simply import and call the hook within your functional components:

import useDarkTheme from '@alikia/dark-theme-hook';

function MyComponent() {
    const isDarkMode = useDarkTheme();

    return (
        <div className={isDarkMode ? 'dark-mode' : 'light-mode'}>
            <h1>Dark Mode Detection</h1>
            <p>Dark mode is {isDarkMode ? 'enabled' : 'disabled'}.</p>
        </div>
    );
}

export default MyComponent;
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago