ComponentmediaZero dependenciesZero dependencies
Use Ticket Audio
SSR-safe WebAudio helper for stamp/punch feedback sounds: lazy AudioContext, volume control, and reduced-motion guard.
Preview
Preview not available.
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add use-ticket-audioOr install the full npm package:
npm install bigbulluiUsage
Starter templateimport { useTicketAudio } from "@/components/ui/lib/use-ticket-audio";
const { muted, toggle } = useTicketAudio({ src: "/sounds/stamp.mp3" });
<button onClick={toggle}>{muted ? "Muted" : "Sound on"}</button>Props
| Prop | Type | Description |
|---|---|---|
| options?.src | string | Optional audio file URL, lazily created on mount. |
| options?.initialMuted | boolean | Initial mute state (default false). |
| result.audioRef | React.RefObject<HTMLAudioElement | null> | Bound audio element ref for custom players. |
| result.muted | boolean | Current mute state. |
| result.setMuted | (muted: boolean) => void | Set mute state directly. |
| result.toggle | () => void | Flip mute state. |