ui

Switch

A control that indicates whether a setting is on or off. Built with Base UI and Tailwind CSS. Copy-paste ready.

API Reference

Installation

Usage

Examples

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

With Description

Add descriptive text below the label to clarify what enabling the switch will do.

Sizes

Render sm, default, and lg size variants side by side to show the available scale options.

Group

Group multiple switches together under a shared heading for related on/off settings.

In Card With Icons

Each setting row pairs an icon, a label, and a switch inside a card — a common pattern for notification or feature-flag preferences.

Destructive Confirmation

A high-impact toggle that shows confirmation text below the switch before the action is committed, preventing accidental activation.

Settings Table

Displays multiple on/off settings as a scannable table with alternating rows, suitable for dense settings panels.

Card Grid

A two-column card grid where each card contains a switch with a title and a short description — ideal for feature or plan settings.

A cookie consent manager grouping switches into Always On, Analytics, and Marketing categories, each with a contextual badge that reflects the current state.

Notification Delivery Channels

A master toggle that enables or disables all delivery channels at once. Individual channel rows (email, SMS, push, Slack) each carry their own switch and are dimmed while the master is off.

Plan Feature Toggles

A feature list where pro features are togglable and enterprise-only features are shown with a badge and rendered as disabled.

Privacy Settings

A permission panel with an icon, label, and description for each setting. A separator divides the media permissions from the tracking and ad preferences.

Dark Mode Toggle

An animated card that transitions between light and dark appearances. Sun and Moon icons flank the switch to reinforce the current mode.

Required Agreement

A sign-up form with a required Terms & Conditions switch. The submit button remains disabled until the user has toggled the switch on.

Do Not Disturb

A do-not-disturb toggle that expands a duration picker when enabled. The icon and description text update to reflect whether the mode is active.