Switch

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

Default

Checked

Disabled

Checked + Disabled

Installation

CLI

Install the component using the StarUI CLI:

star add switch

Examples

Switch with Label

Switch with label, helper text, and reactive feedback

Receive email and push notifications

Auto-save Feature

Document setting with status feedback

Document Settings

Configure how your document is saved

Automatically save changes as you type

Email Subscriptions

Dependent switches for email preferences

Email Preferences

Manage your email subscriptions

Product updates, feature announcements, and tips

Our weekly roundup of news and insights

Newsletter requires marketing emails to be enabled

API Reference

Props

Prop Type Default Description
checked bool | None None Initial checked state of the switch
signal str auto-generated Datastar signal name for state management
disabled bool False Whether the switch is disabled
required bool False Whether the switch is required
cls str '' Additional CSS classes