Example#
Usage#
Use the theme toggle to let visitors switch the paper between Bone and Night. Bone is the default for a first visit (D-C7); the choice is remembered and applied before the first paint, so pages never flash.
icon(default) is a single key in the navbar, pressed on Night, with a circle on Bone and a crescent on Night.segmentedis a two-segment "Bone" and "Night" control, for the footer and the visitor controls.- The switch crossfades in 240 ms where view transitions exist and motion is not reduced; otherwise it is instant.
Anatomy#
- Icon keyPressed on Night.
.mk-theme-toggle - SegmentedBone and Night, for the footer.
.mk-segmented-control
Volume#
Reading layer: identical at every volume.
Quiet
Studio
Press
Rave
Content#
- The papers are named Bone and Night everywhere, never Light and Dark.
Do and don't#
Do
Don't
A theme toggle labelled "Dark mode".
Accessibility#
- The icon key is named "Night stock" and pressed on Night; the segmented pair is a radio group named "Paper".
- The switch crossfades where the browser can and is instant under reduced motion.
| Keys | What happens |
|---|---|
| EnterorSpace on the key | Switches between Bone and Night (aria-pressed = Night) |
| Arrow keys in the segmented control | Pick Bone or Night |
The colour pairs it prints, with their contrast on both papers:
| Text | Surface | Role | Bone | Night |
|---|---|---|---|---|
--mk-text | --mk-surface | ui | not in this look | not in this look |
--mk-on-selected | --mk-selected | ui | not in this look | not in this look |
--mk-on-control | --mk-control | ui | not in this look | not in this look |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
appearance | "icon" | "segmented" | none | |
copy | Partial<ThemeToggleCopy> | none | |
className | string | none |
Tokens#
System tokens (2)
Changelog#
Arrived in 0.1.0.
- The reading layer's controls, overlays, forms and visitor prefs (P2-T1 to P2-T5): every Button is the comic hit key, with IconButton, Link and Tooltip; Input, Textarea, Select, Checkbox and CheckboxGroup, Radio and RadioGroup, Switch, Slider with the ruler, RulerReadout and SegmentedControl; Dialog, Drawer, NavSheet, Tabs, Disclosure, Faq and faqJsonLd on Base UI 1.9 where the platform falls short; Field, Fieldset, Form with the site's inline validation, ErrorSummary, Callout, Honeypot, FormTimestamp and QuoteForm; PrefsScript under 1 KB, usePref and setPref with cross-tab sync, ThemeToggle and the visitor VolumeDial; VisuallyHidden.
- A ruler range keeps its two values apart, a slider's end figures stay inside it, ComparisonTable and the segmented ThemeToggle name their radios per instance (two on a page no longer uncheck each other), and a Stamp's second line wraps, with the big stamp at 0.6× below 30rem. Read the whole entry