@ichiql/react-color-scheme
v0.1.1
Published
Handling system color schemes in React
Downloads
22
Readme
@ichiql/react-color-scheme
pnpm add @ichiql/react-color-scheme
npm install @ichiql/react-color-scheme
yarn add @ichiql/react-color-scheme
React で OS のカラースキーム(テーマ)変更に対応する
React to support OS color scheme (theme) changes.
import { ColorSchemeProvider, useColorScheme } from '@ichiql/react-color-scheme'
return (
<ColorSchemeProvider
initialColorScheme={undefined}
onChangeColorScheme={(colorScheme, isSystemColorScheme) => {
console.log(`!!! colorScheme -> ${colorScheme} / isSystem -> ${isSystemColorScheme}`)
}}
>
~~~
</ColorSchemeProvider>
)
const { colorScheme } = useColorScheme()
return (
<html
lang='en'
data-color-mode={colorScheme}
>
~~~
</html>