Switch

Toggle a single setting on or off.

Installation

import { Switch } from "~/components/ui/Switch";

Usage

<Switch defaultChecked />
<Switch />

API reference

PropTypeDefaultDescription
checkedboolean-Controlled checked state.
defaultCheckedbooleanfalseUncontrolled initial state.
onCheckedChange(checked: boolean) => void-Called when the state changes.
disabledbooleanfalseDisable the switch.

Accessibility

  • Built on the Base UI Switch primitive: full keyboard support and role=switch.
  • State is exposed via data-checked / data-disabled attributes for styling.
View site