Skip to content
OwnlyPlans

Element

Rocker Switch with Click Sound

A clean 3D OFF/ON rocker switch with a crisp mechanical click sound. Real checkbox underneath, keyboard-ready, any ON colour and size.

Remix

Preview and code

Markdown
Toggles and inputs

Install

shadcn CLI
npx shadcn@latest add https://ownlyplans.com/r/bhaskar/rocker-switch-with-click-sound.json

Adds the React files to components/ownlyplans/ in a project set up with shadcn and Tailwind CSS. Or copy them from the Code tab.

About

A minimal on/off rocker with depth: the paddle tips over in 3D, the active side lights up, and it makes a crisp mechanical click (a bright snap, a short woody thock and a tiny spring tick, slightly higher when it turns on). The sound is made in code with the Web Audio API, so there are no audio files to load.

Underneath it is a real checkbox with role=”switch”, so it works in forms (name and value), with Space and Tab, and with screen readers, and it shows a focus ring for keyboard users. Change the ON colour with –rk-on, the size with –rk-size (the whole switch scales from it), the labels in the HTML, and the volume, or turn the sound off with data-sound=”off” on the label. Class names are prefixed (rk-) so they never clash with your own styles.

Based on the open-source switch by Richard Tsang (r7chardgh) on Uiverse.io, customised by OwnlyPlans with the sound, accessibility, options and a React version.

MIT License

Copyright (c) 2023 Richard Tsang (r7chardgh), original switch design on Uiverse.io
Copyright (c) 2026 OwnlyPlans, click sound, accessibility, options and React version

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Changes

  • v1.1 November 8, 2026 Same look as the original switch, cleaner and lighter

Your AI tool
Starter prompt

		

Download the plan