Tactile Switch
Web (React)
One switch in four treatments drawn from the Modus tokens: a flat sprung switch, a pressed-paper tactile slider, Three.js glass and a shader-lit capsule.
A switch that fills its stage, in four styles: a flat switch with a sprung knob in --primary (the default), a tactile slider whose track, knob and mono label come from the theme tokens, a refractive Three.js glass capsule, and a single-shader plasma trough. Every variant follows light and dark appearance automatically, works with keyboard and screen readers, and the WebGL variants react to the pointer. The WebGL variants pause off screen, and with reduced motion every variant snaps instead of animating.
Draft modeOn
Installation
CLI
npx @modus-ui/cli add tactile-switchManual
- Install
three. - Copy the code from the component tab.
- Create a file at
components/ui/tactile-switch.tsx. - Paste the code.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "classic" | "modern" | "glass" | "shader" | "modern" | Which treatment to render. |
mode | "auto" | "dark" | "light" | "auto" | Appearance; "auto" follows the page theme, then the system. |
defaultOn | boolean | true | Initial state. |
label | string | "Draft mode" | Accessible name, also shown on the knob or in the caption. |
speed | number | 1 | Animation speed of the shader variant (0 to 3). |
size | number | 1 | Scale of the switch (0.35 to 2.5). |
opacity | number | 1 | Opacity of the whole stage. |
hue | number | 0 | Hue rotation in degrees. |
saturation | number | 1 | Saturation multiplier. |
brightness | number | 1 | Brightness multiplier. |
onChange | (on: boolean) => void | none | Called with the new state after each toggle. |
Comments