API Reference
<ModeWatcher />
API Reference for the ModeWatcher component.
Usage
Add the ModeWatcher
component to your root +layout.svelte
component.
The ModeWatcher
component will automatically detect the user's preferences and apply/remove the "dark" class, along with the corresponding color-scheme style attribute to the html element.
Disable Tracking
ModeWatcher
will automatically track operating system preferences and apply these if no user preference is set. If you wish to disable this behavior, set the track prop to false:
Default Mode
ModeWatcher
can be configured with a default mode instead of automatically detecting the user's preference.
To set a default mode, use the defaultMode
prop:
Theme Colors
ModeWatcher
can manage the theme-color meta tag for you.
To enable this, set the themeColors
prop to your preferred colors:
Props
The ModeWatcher
component accepts the following props: