Switch

A control that allows the user to toggle between on and off. Plays a toggle sound.

A control that allows the user to toggle between on and off. The sensory-ui Switch plays a toggle sound on state change, confirming the binary state transition.

Pattern: Single-sound

Demo

Live demoSwitch sound packs to compare

Installation

npx shadcn@latest add SatyamVyas04/sensory-ui/sensory-ui-switch

Import

import { Switch } from "@/components/ui/sensory-ui/switch";

Sound Props

PropTypeDefaultDescription
soundSoundRole | false"interaction.toggle"Sound played on toggle.
volumenumber1Per-component volume multiplier (0–1).

Default Sound Role

interaction.toggle

Usage

<div className="flex items-center space-x-2">
  <Switch id="airplane-mode" />
  <Label htmlFor="airplane-mode">Airplane Mode</Label>
</div>

Custom sounds

<Switch sound="interaction.confirm" volume={0.7} />

Disable sounds

<Switch sound={false} />

Customizations

Settings toggles

<div className="flex items-center justify-between">
  <Label htmlFor="notifications">Notifications</Label>
  <Switch id="notifications" sound="interaction.toggle" />
</div>

Destructive toggle

<div className="flex items-center justify-between">
  <Label htmlFor="danger-zone">Danger zone</Label>
  <Switch id="danger-zone" sound="notification.warning" />
</div>

Silent auto-save toggle

<Switch id="auto-save" sound={false} />
{/* No sound for auto-save: it happens frequently */}

Default Props

PropValue
sound"interaction.toggle"
volume1

Tasteful Sound Choices

SituationRecommended SoundWhy
Settings toggleinteraction.toggleDefault: standard state change
Feature enableinteraction.confirmMore significant toggle
Destructive togglenotification.warningWarns of consequence
Auto-save / frequentfalseSound would be repetitive

When to Use

  • Settings: Feature toggles, notification preferences
  • Forms: Binary option inputs
  • Profile: Public/private, active/inactive
  • Any on/off control: Where state change needs confirmation

Avoid sound on

  • Switches that auto-save (sound would be repetitive)
  • Switches inside modals that already play sounds
  • Switches that toggle frequently

Event Triggers

EventDefault Sound
Toggle on/offinteraction.toggle

shadcn/ui Reference

View the original Switch documentation.