-
Notifications
You must be signed in to change notification settings - Fork 0
Wreactui
Nariman Bortov edited this page Jul 4, 2023
·
2 revisions
This page condensates information about the Wreactui component that you may have already seen in Dark theme, Installation and Customization, but gives more details.
import { Wreactui } from '@narimanb/wreactui'
The default Wreactui
component must encapsulate your root component and it doesn't apply any changes by default.
This is only recommended if you just want to provide a single light theme.
Code
// App.js
<Wreactui>
<App />
</Wreactui>
The usePreferences
prop enables these features:
- Theme toggler to switch between themes.
-
prefers-color-scheme
support to automatically change to dark theme if user prefers 'dark' -
localStorage
storing for user preferences so it's consistent on every visit/load.
All of it taken care with single prop
Code
// App.js
<Wreactui usePreferences>
<App />
</Wreactui>
The dark
prop turns the dark theme the default.
Code
// App.js
<Wreactui dark>
<App />
</Wreactui>
You can merge a custom theme (that is, you don't need to create a complete theme, just changing little bits is enough) using the theme
prop.
Code
// App.js
<Wreactui theme={myTheme}>
<App />
</Wreactui>
Prop | Description | Type | Default |
---|---|---|---|
usePreferences |
apply user theme preferences and provide utilities | boolean |
false |
dark |
define dark theme as default | boolean |
|
theme |
theme to merge with defaultTheme
|
objcet |
Original source: Estevan Maito https://windmillui.com/react-ui