ColorModeButton
A button that switches between light and dark.
On this page
Examples
Color mode button
Handled in the browser: it works on static pages and every color mode control stays in sync.
Razor
<KlyColorModeButton data-testid="color-mode-button" />
<KlyColorModeButton Variant="ButtonVariant.Outline" Label="Theme" />
<KlyColorModeButton Color="KlyColor.Primary" Variant="ButtonVariant.Soft" Size="KlySize.Lg" />API
KlyColorModeButton
Button that switches between light and dark mode and stays in sync with the other color mode controls.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
AriaLabel |
string |
Accessible name of an icon-only button. Defaults to the built-in text. | |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Color |
KlyColor |
"neutral" |
Semantic color of the button: a built-in KlyColor or the name of a color you defined. Defaults to neutral. Values: primary, secondary, success, info, warning, error, neutral. |
Label |
string |
Visible text next to the icon. Without it the button is icon-only and needs AriaLabel . | |
Size |
KlySize |
KlySize. |
Size of the color mode button, from Xs to Xl . When not set, Size applies, else the default of the component. Values: Xs, Sm, Md, Lg, Xl. |
Variant |
ButtonVariant |
ButtonVariant. |
Look of the button: Solid , Outline , Soft , Subtle , Ghost or Link . Defaults to Ghost . Values: Solid, Outline, Soft, Subtle, Ghost, Link. |