ThemeSwitch <pm-theme-switch>
Light / dark / system switch.
Variants
Set with the variant attribute.
variant="segmented"variant="toggle"Sizes
Set with the size attribute; controls keep touch-sized targets on phones.
size="sm"size="md"Tones
Set tone on the element, or data-tone on any ancestor to tone a whole area.
tone="accent"tone="secondary"tone="neutral"tone="success"tone="warning"tone="danger"tone="info"Overview
On its own it sets data-mode on <html> and saves the choice where the no-flash script and ThemeController read it. Give it a controller (a ThemeController) to stay in sync with the rest of your app and across tabs.
variant="toggle" is one button that flips between light and dark; the default shows all three choices.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
variant | 'segmented' | 'toggle' | — | segmented (default: light, dark, system) or toggle (one button, light ↔ dark). |
size | 'sm' | 'md' | — | sm or md (default): the height of a button of the same size, in both variants. |
label | string | — | Accessible name (default "Colour mode"). |
show-labelsprop: showLabels | boolean | — | Show the words next to the icons. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-change | onPmChange | The mode changed. |
Used in templates
Overview dashboardTraffic analyticsOrdersCustomer 360InboxTeam chatAI assistantNotificationsProject boardTeam and rolesBilling and invoicesUser profileAccount settingsSign inCreate accountTwo-step verificationForgot passwordChoose a new passwordPricing plansProduct pageShopping cartCheckoutLanding pageArticleChangelogHelp centreContactComing soonNot found (404)Server error (500)Onboarding wizardAppointment bookingFeedback survey