Sound Toggle
A speaker button that turns interface sounds on or off: waves ripple out while it's on and a slash draws across when it's off. Remembers the choice and switches UI Sounds everywhere on the page.
- Category: Sounds
- Licence: Free, MIT
- Built with: React 19, Tailwind CSS 4, Motion
- Dependencies: motion, clsx, tailwind-merge
Examples
Sound Toggle
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
onChange | (on: boolean) => void | — | |
size | "sm" | "md" | "md" | |
className | string | — |
About Sound Toggle
Sound Toggle is the switch for interface sounds: sound waves ripple out while it is on, and a slash draws across when it is off. It remembers the choice and switches UI Sounds everywhere on the page.
Sound Toggle is an UI sound effect for React 19, styled with Tailwind CSS 4 and animated with Motion. It drops into Next.js, Vite, Remix or Astro through the shadcn CLI as a single file you own.
When to use Sound Toggle
- Site headers with sound effects.
- Games and playful apps.
- Settings and preference panels.
- Accessibility and comfort controls.
How it works
It is a switch role with aria-checked. The preference lives in localStorage and a page event, which UI Sounds also reads, so both stay in sync without importing each other.
Sound is always secondary: it is muted until you allow it, respects a global mute, and never carries information that is not also shown on screen. With prefers-reduced-motion on, it holds still or settles instantly instead of animating.
Customizing Sound Toggle
Every prop is documented in the API reference above with its type and default. The ones you will reach for first are listed here.
The Customize panel next to the preview lets you change size live, and the Code tab updates to match, so the snippet you copy already carries your values.
- size ("sm" | "md", default "md").
Goes well with Sound Toggle
These sounds pieces share its tokens and motion language, so they sit together on one page without clashing.
- UI Sounds: 45 React UI sounds synthesised live with Web Audio, no audio files
Install Sound Toggle
npx shadcn@latest add https://charcoalui.com/r/sound-toggle.jsonSound Toggle is free and MIT licensed. The command copies sound-toggle.tsx into components/ui and installs clsx, tailwind-merge; you can also copy the source from the Code tab by hand.
Charcoal UI Pro adds 393 more showpiece components, 112 sections and 100 templates built the same way.
Frequently asked questions
- How do I install Sound Toggle?
- Run npx shadcn@latest add https://charcoalui.com/r/sound-toggle.json. The shadcn CLI copies sound-toggle.tsx into components/ui and installs motion, clsx, tailwind-merge. You can also copy the source from this page by hand.
- Is Sound Toggle free for commercial use?
- Yes. Sound Toggle is MIT licensed: use it in any personal or commercial project and change it however you like.
- Does Sound Toggle work with Next.js?
- Yes. It is a client component for React 19 styled with Tailwind CSS 4, so it works in the Next.js App Router and Pages Router, Vite, Remix and Astro.
- Can an AI coding agent install Sound Toggle?
- Yes. Connect the Charcoal UI MCP server (https://charcoalui.com/mcp) to Claude Code, Cursor or any MCP client; get_component returns Sound Toggle's props and source and get_install_command returns the exact command.