byronwade/ui
Application UI

Forms · Application UI

Switch

A toggle switch component built on Base UI's Switch primitive that supports two sizes and accessible checked/disabled states.

Feature showcase

Installation

Features

  • 6 examples

    Default, Controlled, Disabled, Invalid, Sizes, With Label.

API

Props

PropTypeDefaultDescription
size"sm" | "default""default"Controls the dimensions of the switch track and thumb.
classNamestring-Additional CSS classes merged onto the root element.
defaultCheckedboolean-Uncontrolled initial checked state (from Base UI Root props).
checkedboolean-Controlled checked state (from Base UI Root props).
onCheckedChange(checked: boolean) => void-Callback fired when the checked state changes (from Base UI Root props).
disabledboolean-Disables the switch and applies reduced-opacity styling (from Base UI Root props).

Source and related

FilePath
Componentregistry/ui/switch.tsx
Default examplecontent/examples/switch/default.tsx
Controlled examplecontent/examples/switch/controlled.tsx
Disabled examplecontent/examples/switch/disabled.tsx
Invalid examplecontent/examples/switch/invalid.tsx
Sizes examplecontent/examples/switch/sizes.tsx
With Label examplecontent/examples/switch/with-label.tsx