Sound
Optional, synthesized sound for icons and components: props, provider, global volume and mute, browser autoplay rules and accessibility.
Every Popcons icon and component can play a short sound on interaction. Icons play a sound that fits the object (a bell rings, a trash can crumples, a bicycle dings, a camera clicks), and UI components are on by default with sounds that fit what they do. There are no audio files (sounds are synthesized with the Web Audio API from small recipes), sound only starts from a click or key press, and the engine only loads when sound is in use. This site has sound on; mute it with localStorage.setItem("popcons:sound", "off").
Icons (React)
import { BellIcon } from "@popcons/react";
<BellIcon /> {/* silent (default) */}
<BellIcon sound /> {/* the icon's own sound, on hover and keyboard focus */}
<BellIcon sound="success" /> {/* force a recipe */}
<BellIcon sound volume={0.4} /> {/* 40% of the global volume */}
<BellIcon sound trigger="click" /> {/* plays on click instead */}| Prop | Type | Default | Description |
|---|---|---|---|
sound | boolean | RecipeName | false | true plays the icon's own sound. A recipe name plays that recipe instead. |
volume | number (0 to 1) | 1 | Multiplied with the global volume. |
Sound plays on the same events as the animation: hover and keyboard focus for trigger="hover", click for trigger="click". Looping and in-view triggers never make sound. Each icon's recipe comes from its name: a bell rings, a trash can crumples and thuds, a bird chirps, a bicycle dings its bell, a car honks, a camera clicks its shutter, a lock latches, a heart beats, a flame crackles, a check mark sounds like success. Icons with no natural sound (arrows, chevrons, shapes, layout glyphs) share one soft generic click. Pitch shifts slightly with size and per icon, so a set does not sound identical.
Provider
import { PopconsProvider, setVolume } from "@popcons/react";
<PopconsProvider sound volume={0.6}>
<App /> {/* every icon below defaults to sound on; an icon's own sound prop wins */}
</PopconsProvider>
setVolume(0.5); // global master volume, 0 mutes everythingComponents
Interactive components (buttons, switches, checkboxes, tabs, toasts, dialogs, sheets, sliders, steppers, rating stars, progress bars and the game-style pack components) accept sound and volume props and play by default: a click for buttons, on and off tones for switches, a tick for checkboxes and tabs, an open or close whoosh for dialogs, a chime for toasts, a success tone when progress completes. State-driven ones play when the state changes after mount, never on first render. Wrap your app in SoundProvider once and every other control below it (any button, switch, checkbox, tab, disclosure, slider, text field, and avatars, each with a short voice seeded by its name) is voiced too. Pass sound= to a component, set sound= on the provider, or put data-pc-sound="off" on a region to silence it.
import { SoundProvider, Switch, Button } from "@popcons/ui";
<Switch label="Wi-Fi" /> {/* on by default */}
<Switch label="Quiet" sound={false} /> {/* silenced */}
<SoundProvider>
<Button>Save</Button>
</SoundProvider>Installing a component with the CLI also installs the two small sound files it needs (popcons-sound and popcons-use-sound) as registry dependencies.
Global volume and mute
setVolume(0..1)andgetVolume()set the master volume for everything on the page.setSoundEnabled(false)is a kill switch for all Popcons sound.- The
popcons:soundlocalStorage key is respected: the valuesoff,0orfalsemute everything. - Everything goes through a limiter, so stacked sounds cannot clip. Rapid repeats are throttled (60 ms per sound), get softer, and at most 8 sounds play at once.
Browser autoplay rules
Browsers only allow audio after a user gesture. Popcons listens for the first pointer press or key press and unlocks audio then. A sound requested before that is skipped, not queued, so nothing suddenly plays later. Hover alone is not a gesture, so on a fresh page the first hover is silent and later ones play.
Accessibility
- Sound only ever comes from an interaction (click, key press, typing) or a state change the user caused. Never on page load, never on mount, never on hover alone for components, and not before the first user gesture.
- Never rely on sound for information. Every sound accompanies a visual change, and nothing is conveyed by sound alone.
- It respects the user: the
popcons:soundpreference and the global mute win over a component'ssoundprop. Offer your own sound toggle in your product. - Reduced motion and sound are separate settings. A visitor who asks for reduced motion still gets sound if you or they turned it on, because it is not motion.
- Every component can be silenced with
sound=.
Exports
In the customizer or the API ({ "sound": true } in the export request), the React and Vue exports include an opt-in sound prop and import a sibling popcons-sound.ts file (a tiny single-file synth with the object sounds, no dependencies). Keep that file next to the components. The icon set zip adds it to the react/ and vue/ folders.
SVG, CSS/HTML, Lottie and Rive exports have no sound and are identical with or without the option.
Recipes
The base recipes are click (the one generic sound), check, uncheck, open, close, copy, tap, pop, toggle-on, toggle-off, success, error, warning, notify, whoosh, swipe, tick, type, coin, level-up, charge and thud. About 70 object recipes sit on top (bell, trash, bird, bike-bell, horn, shutter, latch, heartbeat, crackle, gust, melody, ring, tick-tock, alarm, rumble, keys, fanfare, launch, bark, meow and more). Each is a few oscillator and noise layers with a pitch and filter sweep, defined as plain objects in the engine file.