examples/switch-minimal.tsx
import { Switch } from "@/components/wensity/switch";export function SwitchMinimal() {return (<SwitchdefaultCheckedlabel="Reduce motion"description="Use shorter transitions across the interface."/>);}
A React toggle switch on Base UI in minimal, elevated, segmented, and power styles, with labels on either side, settings groups, and switch cards.
Practical examples and common states for the same installable component.
Clean pill switch for common settings.
Extra depth on the knob for heavier settings panels.
On/off labels inside the control for explicit mode switching.
Icon-first switch for security and critical toggles.
Group related switch controls with shared context.
Validation state for required switches.
Disabled switch states stay readable while blocking interaction.
Theme-token styling that adapts cleanly to both appearances.
Switch is a React and Tailwind CSS toggle switch on Base UI, in Next.js or any React app, for settings that take effect immediately. Four looks share one API: a minimal pill, an elevated knob, a segmented Off and On control, and a round power button that swaps its icon for a check. The whole row is a label, so clicking the words flips it. SwitchGroup and SwitchSettingsGroup stack rows into a bordered settings panel, while SwitchCard can show different trailing text per state and announces the change. Use a checkbox when nothing should happen until submit.
Run the following command
pnpm dlx wensity@latest add switch
npx wensity@latest add switch
yarn dlx wensity@latest add switch
bunx wensity@latest add switch
Import Switch from @/components/wensity/switch and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.
import { Switch } from "@/components/wensity/switch";export function SwitchDemo() {return (<Switchlabel="Push notifications"description="Receive alerts for messages, mentions, and activity."defaultChecked/>);}
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | - | Controlled on/off state. |
defaultChecked | boolean | false | Initial state when the switch is uncontrolled. |
onCheckedChange | (checked: boolean, eventDetails?: unknown) => void | - | Called when the switch is toggled. |
label | React.ReactNode | - | Label beside the control, wired to it so the text is clickable. |
description | React.ReactNode | - | Secondary copy under the label. |
error | React.ReactNode | - | Error message under the control, with invalid styling applied. |
switchSize | "sm" | "md" | "lg" | "md" | Track and thumb size, plus label text size. |
variant | "minimal" | "elevated" | "segmented" | "power" | "minimal" | Track treatment. power renders the icon-style toggle. |
labelPosition | "left" | "right" | "right" | Which side of the control the label sits on. |
fullWidth | boolean | true | Stretches the row to fill its container, pushing the control to the far edge. |
containerClassName | string | - | Classes for the row wrapper around control and label. |
controlClassName | string | - | Classes for the switch track itself. |
A React checkbox on Base UI with checked, unchecked, and indeterminate states, labels, descriptions, errors, checkbox groups, and selectable cards.
A React toggle button and toggle group on Base UI in default, icon, outline, and soft styles, with a sliding segmented mode or multi select for toolbars.
A React radio group on Base UI with a gliding dot, a segmented control style, bordered rows, and radio cards for plan and shipping pickers.
A React form field wrapper that wires a label, description, and error to one control, with stack, inline, split, and card layouts plus form sections.

Pricing cards with a monthly and annual toggle, prices that spring to new values, and a highlighted plan in a brand glow.

A physical stack of photo cards shuffled to the front by clipped tabs, with a tight image inset and copy in the footer.

Tools share one liquid panel. It pours out of the icon you click, stretches to the next one, then drains back in.

Frosted glass that bends the page at its edge, with a rim that catches the light.