Skip to content

Switch

A control that indicates whether a setting is on or off.

API Reference

Installation

pnpm dlx shadcn@latest add @frontal-labs/switch

Usage

import { Switch } from "@/components/ui/switch";
<Switch />

API Reference

Switch

Styled wrapper for Switch.Root from Base UI with built-in thumb.

All other props from Switch.Root are supported.

The checked track uses the brand colour (bg-brand) with a bg-brand-foreground thumb, so an enabled switch reads as a brand affordance rather than a neutral primary fill. The unchecked track uses bg-input. The root carries cursor-pointer, and cursor-not-allowed when disabled.

Examples

For accessible labelling and validation, prefer using the Field component to wrap checkboxes. See the related example: Switch field.

Disabled

With Description

Small Size

Use the size prop to render a smaller switch. Track and thumb scale together.

<Switch size="sm" />

Card Style

Form Integration