Switch

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

Checkbox Group

Since a Switch is a Checkbox underneath, it can also be used in a CheckboxGroup.

Value: [ "recents", "home", "applications", ]

Sidebar

Select the items you want to display in the sidebar.

Description

Focus is shared across devices, and turns off when you leave the app.

Choice Card

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

Disabled

Set the disabled prop on either the Switch or the Field to render it disabled.

Invalid

Set the invalid prop on either the Switch or the Field to render it invalid.

You must accept the terms and conditions to continue.

Size

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

Anatomy

Import all parts and piece them together.

use leptos::prelude::*;
use singlestage::Switch;

#[component]
pub fn SwitchAnatomy() -> impl IntoView {
    view! { <Switch /> }
}

API Reference

switch

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

Custom Attributes
NameTypeDefaultDescription
checkedboolfalse

A reactive signal coupled to the Switch's checked value.

invalidboolfalse

Set whether to render the Switch as invalid.

sizeString"default"

Set the size to render the Switch.

Implements global, input, and checkbox attributes.