Thrive Design System

Components

Switch

A toggle control for switching between two mutually exclusive states like on/off or enabled/disabled.

Installation

npm install @thrivecart/ui
yarn add @thrivecart/ui
pnpm add @thrivecart/ui
bun add @thrivecart/ui

Usage

import { Switch } from '@thrivecart/ui';

Examples

Basic Switch

Default

Simple on/off toggle

<div className="flex items-center gap-2">
<Switch id="airplane-mode" />
<Label htmlFor="airplane-mode" className="font-normal">Airplane Mode</Label>
</div>

Disabled

Disabled

Non-interactive switch

<div className="flex items-center gap-2">
<Switch disabled checked />
<Label className="font-normal text-ink-light">Feature locked</Label>
</div>

Best Practices

Pair with a label

Always include a visible label that describes what the switch controls.

Use for immediate effects

Switches should apply changes immediately without requiring a save action.

Don't use in forms

For form fields that get submitted, use Checkbox instead of Switch.

Don't use negative labels

Avoid labels like "Disable notifications." Use positive framing: "Enable notifications."

Props

Props

Accessibility

  • Toggled with Space key when focused.
  • Uses role="switch" with aria-checked for state.
  • Label association via id and htmlFor.
  • Focus indicator is clearly visible.