Theme Switch
A component that allows users to switching themes of the application dynamically.
Usage
Examples
As Toggle
By default, ThemeSwitch
will appear as a toggle button, switching between light
and dark
mode, just like below.
Important
Make sure your application is wrapped with ThemeProvider
before using
ThemeSwitch
component.
As Select
You can also use ThemeSwitch
as a select dropdown, allowing users to choose from a list of themes.
Custom Themes
You can also extend themes available by defining the themes
property! This also lets you to customize the theme icons or change up the order of themes.
Props
ThemeSwitch
Prop | Type | Default |
---|---|---|
as | enum | toggle |
themes | Theme[] |
|
ThemeProvider
Prop | Type | Default |
---|---|---|
defaultTheme | string | light |
children | ReactNode | - |