Theme toggle
Cycles light → system → dark, saves the choice in localStorage (key hc-site-theme, as on hackclub.com) and keeps every toggle on the page in sync. To avoid a flash of the wrong theme, inline themeScript in your <head>.
<hc-theme-toggle></hc-theme-toggle>
<hc-theme-toggle variant="labeled"></hc-theme-toggle>setTheme(), getThemePreference(), applyTheme() and the hc-theme-change event are exported for custom controls.API
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
variant | "icon" | "labeled" | "icon" |
CSS parts
| Name | Description |
|---|---|
button |