110k
New

Switch

A control that allows the user to toggle between checked and not checked.

Component switch-demo not found in registry.

Installation

pnpm dlx createui@latest add switch

Usage

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

Examples

Description

Component switch-description not found in registry.

Choice Card

Card-style selection where FieldLabel wraps the entire Field for a clickable card pattern.

Component switch-choice-card not found in registry.

Disabled

Add the disabled prop to the Switch component to disable the switch. Add the data-disabled prop to the Field component for styling.

Component switch-disabled not found in registry.

Invalid

Add the aria-invalid prop to the Switch component to indicate an invalid state. Add the data-invalid prop to the Field component for styling.

Component switch-invalid not found in registry.

Size

Use the size prop to change the size of the switch.

Component switch-sizes not found in registry.

API Reference

See the Base UI Switch documentation.