Sound is off until a visitor turns it on (D-H4). The toggle only sets the preference; the sound engine obeys it and opens its audio context inside that same click. Quiet stays silent, Studio plays a little softer.
Example#
Usage#
Use the sound toggle wherever the site can make sound. Sound is off until a visitor turns it on (D-H4); the toggle sets the preference, and the sound engine plays only while it is on.
icon(default) is an icon key with the sound-on and sound-off glyphs;labelledsays the state in words, "Sound off" or "Sound on", for the visitor controls.- No audio until asked. The engine opens its audio context inside the click that turns sound on, so nothing loads before.
Anatomy#
- Icon keyPressed while sound is on.
.mk-sound-toggle.mk-icon-button - Labelled keySound off or Sound on, in words.
.mk-sound-toggle.mk-button
Volume#
Reading layer: identical at every volume. Sound is never tied to the volume: Rave stays silent until a visitor asks.
Quiet
Studio
Press
Rave
Content#
- The words are "Sound off" and "Sound on"; the key's name says the current state.
Do and don't#
Do
Don't
A page that plays a wood knock on load and offers a mute key.
Accessibility#
- A real
buttonwitharia-pressed: pressed means sound is on. The icon key's name and the labelled key's words say the state, "Sound off" or "Sound on", and the speaker glyph follows. - The choice persists (
localStorage mk-sound) andPrefsScriptsets<html data-mk-sound>before the first paint. - Nothing plays before a visitor asks for it, and reduced motion does not mute it: sound is not motion.
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
appearance | "icon" | "labelled" | none | |
copy | Partial<SoundToggleCopy> | none | |
size | Size | none | The key size (40 / 44 / 52 px icon squares; 40 / 48 / 56 px labelled keys). |
className | string | none |
Tokens#
System tokens (5)
Changelog#
Arrived in 0.1.0.
./sound: the engine (knocks, stamp, pop), themk:sfxbus,SoundToggleand the four CC0 wood knock clips. Read the whole entry