Skip to content

Switch

The Switch component provides a toggle for a single on/off setting that takes effect immediately. It is built on the Radix UI Switch primitive with design-system styling, and can be paired with an optional label and caption.

Installation

import { Switch } from "@harnessio/ui/components";
// Controlled
<Switch
id="airplane-mode"
checked={airplaneModeEnabled}
onCheckedChange={setAirplaneModeEnabled}
label="Airplane mode"
caption="Enable or disable airplane mode to control all wireless communication."
/>
// Uncontrolled — set the initial state with defaultChecked
<Switch id="notifications" defaultChecked label="Enable notifications" />