Light Mode First
With this approach, you declare your light
colors first and then use
[data-theme="dark"]
to set your dark
colors.
Show code
Dark Mode First
With this approach, you declare your dark
colors first and then use
[data-theme="light"]
to set your light
colors.
Show code
Load theme on page load
If you want to load the theme before the page is rendered, you can import
load-theme.ts
file in your index.html
or respective entry point:
If you are using Astro, you can use loadTheme
util
in your layout:
Custom key for localStorage
Use the customKey
prop to set a custom key for localStorage
to store the
theme.
API
See documentation below for reference to all of the props, classes and CSS
variables (custom properties) available for <ThemeButton />
: