Switch
A switch whose thumb stretches toward the other side while it is pressed, then slides across.
Examples
Default
Wrap it in a <label> with its text, so a press on the text turns it too, and name it from the title alone. Hold it down and the thumb stretches toward the side it will go to.
Settings
One switch per row, at the end. Name it from the title with aria-labelledby, point aria-describedby at the description, and say why beside a disabled one.
Small
Set size="sm" in a table or a menu. A switch with no text beside it needs aria-label.
Saving
Move it at once and make it readOnly while the change saves. If the save fails, set it back: the thumb slides back and the row says why.
Display options
In a menu
Each option is a <label>, so a press anywhere on the row turns it. Long text wraps, and the switch stays beside its first line.
Installation
npx shadcn@latest add https://kinoui.com/r/switch.json- Files
lib/reduce-motion.tslib/resize.tslib/choice.tscomponents/kino/switch.tsx- Packages
@base-ui/reactclass-variance-authority- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
Props
Data attributes
Accessibility
- It is a switch to assistive technology, announced as on or off. Space turns it, and a press on its
<label>does too. - A switch with no text beside it needs
aria-label, such as "Send to api.kinoui.com". - On and off differ in where the thumb sits, not only in colour. In forced colours the track fills with the system highlight when on.
- When the system asks for less motion, the thumb moves at once and doesn’t stretch over time; the colours still fade.