9.2k

Switch

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

API Reference

Installation

Usage

API Reference

Switch

Styled wrapper for Switch.Root from Base UI with built-in thumb. Size is controlled via the --thumb-size CSS variable.

Examples

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

Disabled

With Description

Customizing Size

The switch size is controlled by the --thumb-size CSS variable. By default, the switch uses responsive sizing with [--thumb-size:--spacing(5)] sm:[--thumb-size:--spacing(4)] classes, making it slightly larger on mobile devices (like other interactive elements).

You can customize the size by overriding these CSS variable classes on the component. The --thumb-size value can be expressed using:

  • The spacing scale: --spacing(3), --spacing(4), --spacing(5), etc.
  • Fixed units: 1rem, 16px, etc.

Card Style

Form Integration

coss.com ui

Built by and for the team of Cal.com, Inc. — the leading commercial open source company (“coss”).