ThemeProvider
daisyUI theme provider. Manages the selected theme (any enabled daisyUI theme, or the
special "system" value which follows the OS light/dark setting), applies it to the
document data-theme attribute via IJSRuntime, and persists the choice
to localStorage + cookie. Cascades itself so descendants can read ThemeProvider.Preference /
ThemeProvider.Theme / ThemeProvider.IsDarkMode and call SetThemeAsync(System.String).
Brand-neutral: the light/dark theme applied for "system", the set of selectable themes,
and the set of themes considered “dark” are all parameter-driven, so any application can plug in
its own daisyUI themes without modifying this component.
Properties
Section titled “Properties”ChildContent
Section titled “ChildContent”Content rendered inside the provider; receives this as a cascading value.
CookieKey
Section titled “CookieKey”Cookie name for the preference (so the server can read it during SSR). Defaults to daisy-theme.
DarkModeCookieKey
Section titled “DarkModeCookieKey”Cookie name for the resolved theme (so SSR can paint the right theme). Defaults to daisy-darkmode.
DarkThemes
Section titled “DarkThemes”Themes considered “dark” (used to resolve ThemeProvider.IsDarkMode). Defaults to ThemeProvider.DaisyUiDarkThemes.
InitialIsDarkMode
Section titled “InitialIsDarkMode”Kept for backwards compatibility; no longer used to seed state (the resolved theme cookie is preferred).
InitialPreference
Section titled “InitialPreference”Initial preference read by the consumer (typically from the server-side cookie during SSR) to avoid
a flash of the wrong theme on first paint. May be a theme name or "system". Pass null to skip.
IsDarkMode
Section titled “IsDarkMode”Whether the applied theme is a dark theme.
OnThemeChanged
Section titled “OnThemeChanged”Raised after the applied theme changes (e.g. to refresh a theme picker).
Preference
Section titled “Preference”Current selection: a theme name, or "system".
StorageKey
Section titled “StorageKey”localStorage key for the saved preference. Defaults to daisy-theme.
SystemDarkTheme
Section titled “SystemDarkTheme”Theme applied for ThemeProvider.SystemPreference when the OS is in dark mode. Defaults to dark.
SystemLightTheme
Section titled “SystemLightTheme”Theme applied for ThemeProvider.SystemPreference when the OS is in light mode. Defaults to light.
The daisyUI theme actually applied (resolves "system" to a concrete theme).
Themes
Section titled “Themes”All selectable themes, in display order. Must stay in sync with the themes: list enabled
in your Tailwind/daisyUI css. Defaults to all 35 built-in daisyUI themes (ThemeProvider.DaisyUiThemes).
Methods
Section titled “Methods”OnAfterRenderAsync(bool)
Section titled “OnAfterRenderAsync(bool)”OnInitialized()
Section titled “OnInitialized()”ResolveTheme(string, bool)
Section titled “ResolveTheme(string, bool)”Resolves a preference (theme name or “system”) to a concrete daisyUI theme.
SetThemeAsync(string)
Section titled “SetThemeAsync(string)”Selects a theme and persists it. Pass any value from ThemeProvider.Themes, or
ThemeProvider.SystemPreference to follow the OS setting.
Fields
Section titled “Fields”_preference
Section titled “_preference”The persisted choice: a theme name, or ThemeProvider.SystemPreference.
_resolved
Section titled “_resolved”The actual daisyUI theme currently applied to data-theme.
DaisyUiDarkThemes
Section titled “DaisyUiDarkThemes”The built-in daisyUI themes that use a dark color scheme. Default for ThemeProvider.DarkThemes.
DaisyUiThemes
Section titled “DaisyUiThemes”The 35 built-in daisyUI v5 themes, in display order. Used as the default for ThemeProvider.Themes.
SystemPreference
Section titled “SystemPreference”The special preference value that follows the OS light/dark setting.