Sound
A React component in Beamline's Motion & effects category.
Opt-in interface cues with scoped volume, graceful mute and bounded repetition; soft tactile gestures and restrained result tones.
Use it for
- Products that want tactile feedback, as a user setting.
Not for
- Default-on sound, or sound as the only feedback.
Anatomy
- SoundProvider: enabled defaults to false. Provider-local volume defaults to 0.5 and clamps to 0–1; zero mutes. Volume changes release current cues and apply the new level to subsequent cues. Other providers and media keep their own level.
- useSound().play(name): call from an interaction; returns a Promise with started, muted, unavailable, coalesced or cancelled. Existing callers may ignore the result. Started confirms browser scheduling, not physical speaker output.
- useSound().stop(): releases the active cue and invalidates pending unlock. Mute, unmount and audio interruption do the same; no shared context is disposed.
- useSound().status and lastSound: muted, ready, playing or unavailable; lastSound names the last cue actually started. Enabled alone never means playing.
- Repetition: one active cue plus its short release tail. Calls within 70 ms (90 ms for tick), or during unlock, coalesce without a queue. Ticks do not interrupt result cues. Unlock expires after 250 ms and late completion cannot play.
- soundPresets: exact production definitions for @web-kits/audio renderToBuffer or renderToWav. For example, renderToBuffer(soundPresets.tap, { duration: 1, sampleRate: 48000 }, { volume: 0.5 }). Provider lifecycle still needs real browser verification.
Variants
- name: tap, select, destructive, toggleOn, toggleOff, open, close, tick, success, error
States
- muted (default or zero volume)
- ready (enabled; no playback claimed)
- playing (voice started on a running audio context)
- unavailable (unsupported, refused, interrupted or expired unlock)
Keyboard
- n/a
Motion
n/a
Props
| Prop | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Explicit user opt-in; defaults to false. |
volume | number | 0.5 | Linear multiplier 0–1; defaults to 0.5. Zero or a non-finite value mutes. |
children (required) | ReactNode | — |
Used in
Dependencies
@web-kits/audio
Import
import { SoundProvider, useSound } from "@beamline/sound";
Get it
Sound is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in Motion & effects
- Light band: A band of split light in the dark behind a section, blue at one end and amber at the other with a bright core: Prism's light at a chosen place, a hero…
- Halftone Dots: A picture rebuilt as a field of dots whose size follows brightness; a new picture morphs the dots, a click ripples through, the pointer pushes dots aside.
- Glow: Ambient light around one element that says something is happening: an aurora under a working composer, or a ring of light round a live card.
- Liquid gooey: Liquid surfaces that merge like goo when they touch — split plus-menus, gooey switches, file chips.