theme-wc
Theme selection component for color mode (light/dark/auto) and brand themes.
Overview
The <theme-picker> component provides a UI for users to select their preferred color mode and brand theme. It integrates with ThemeManager for persistence and system preference detection.
Inline Variant
For settings pages, use the inline variant which is always visible:
Trigger Variants
Text Button
Simple text trigger:
Icon-Only Button
For compact layouts, use an icon-only trigger with an accessible label:
Custom Styling
Apply button variant classes to match your design:
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
data-variant |
popover, inline |
popover |
Display mode - popover with trigger or always visible |
data-open |
boolean | - | Reflected attribute indicating open state (popover only) |
ThemeManager API
For programmatic theme control, use the ThemeManager module:
Available Themes
Color Modes
| Mode | Description |
|---|---|
auto |
Follows system preference (prefers-color-scheme) |
light |
Forces light mode |
dark |
Forces dark mode |
Brand Themes
| Theme | Primary Hue | Description |
|---|---|---|
default |
260 (purple) | Default brand colors |
ocean |
200 (teal) | Cool blue-green palette |
forest |
145 (green) | Natural earthy greens |
sunset |
25 (orange) | Warm orange-red palette |
Creating Custom Themes
Create new brand themes by copying the template:
Edit the hue values (0-360):
Register in src/tokens/themes/index.css:
Hue Reference
| Hue Range | Colors |
|---|---|
| 0-30 | Red / Orange |
| 30-60 | Orange / Yellow |
| 60-120 | Yellow / Green |
| 120-180 | Green / Cyan |
| 180-240 | Cyan / Blue |
| 240-300 | Blue / Purple |
| 300-360 | Purple / Red |
Preventing FOUC
To prevent a flash of unstyled content, add this inline script to your HTML <head>:
Events
| Event | Detail | Description |
|---|---|---|
theme-wc-open |
- | Fired when popover opens |
theme-wc-close |
- | Fired when popover closes |
theme-change |
{ mode, brand, effectiveMode } |
Fired on window when theme changes |
Accessibility
- Popover uses
role="dialog"witharia-label - Radio groups use proper
role="radiogroup" - Trigger button announces expanded state via
aria-expanded - Escape key closes the popover
- Focus is trapped within popover when open