GitHub

Feedback

Opt-in haptics and click sounds for controls, in the spirit of Apple platforms.

FeedbackProvider turns on short haptics, and optionally soft synthesized clicks, for the controls inside it. Feedback is off by default, so components behave exactly like their primitives until you enable it.

Loading example…

Installation

pnpm dlx shadcn@latest add @sui/feedback

Install with the shadcn CLI or use the shared @workspace/ui package. Follow the installation guide to configure the registry, load styles, and choose import aliases.

Usage

import { FeedbackProvider } from "@workspace/ui/components/feedback"
<FeedbackProvider haptics>
  {/* Your app content */}
</FeedbackProvider>

Add sound for clicks as well. Most Apple controls stay quiet, so haptics alone is the closer match.

Per component

Every supported component takes a feedback prop that overrides the provider for that instance.

ValueEffect
unsetFollows the nearest FeedbackProvider; silent without one.
trueHaptics and sound.
"haptic"Haptics only.
"sound"Sound only.
falseSilent, even inside an enabled provider.
<Switch feedback="haptic" />
<Button feedback>Save</Button>

Button stays silent unless feedback is set, even inside an enabled provider, because most buttons should not tap back.

Moments

ComponentWhenHaptic
SwitchToggledlight; rising or falling click
Checkbox, RadioGroup, ToggleSelection changesselection
Tabs, ToggleGroup, TabBarSelection changesselection
TabBarLong press, then each item passed while slidingmedium, then selection
SliderReaching either end; each step when there are 20 or fewerlight; selection
BottomSheet, DrawerSettling on a detent or snap pointlight
WheelPickerEach row crossedselection, tick
ToasterA success, warning or error toast appearsnotification
CopyButton, CopyTextCopy succeeds or failssuccess or error
InputOTPstatus turns success or errorsuccess or error
ButtonClickedlight; medium for destructive

Platform support

  • Android and other browsers with the Vibration API play a timed pattern for each kind.
  • iOS 18 and later have no Vibration API. A hidden <input type="checkbox" switch> plays the system Taptic click, so notification kinds differ by the number of clicks.
  • Desktop has no haptics; only sound plays.

Browsers only allow haptics during a user gesture. Feedback that follows asynchronous work, such as a copy result or a toast, may not vibrate on iOS. Sound never plays before the first user interaction.

useFeedback

useFeedback returns a stable trigger(kind, sound) for your own components. It follows the provider and accepts the same feedback option.

import { type FeedbackOption, useFeedback } from "@workspace/ui/components/feedback"

function Stepper({ feedback }: { feedback?: FeedbackOption }) {
  const trigger = useFeedback(feedback)
  return <button onClick={() => trigger("selection", "tick")}>+</button>
}

kind is one of "selection", "light", "medium", "heavy", "success", "warning" or "error". sound is "tick", "tap", "toggle-on" or "toggle-off", or false for haptics only. Pass { optIn: true } as the second argument to ignore the provider, as Button does.

API Reference

FeedbackProvider

PropTypeDefault
hapticsbooleanfalse
soundbooleanfalse