Package Exports
- @alikia/dark-theme-hook
- @alikia/dark-theme-hook/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@alikia/dark-theme-hook) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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-hookyarn add @alikia/dark-theme-hookpnpm add @alikia/dark-theme-hookbun add @alikia/dark-theme-hookUsage
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;