Controls

Switch

A toggle component that allows users to enable or disable a setting with a smooth transition effect.

Basic

A switch is a toggle that flips between on and off, similar to a light switch.

Loading...

Installation

If you hit any issues, make sure you check out the installation guide here for more information.

Composed components

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

The Switch comes packed with several components to enhance functionality and provide a seamless experience.

FieldField's a core piece every other component uses. It flexes reusable styles, showing up in inputs, labels, descriptions, and more.

Manual installation

Make sure you also install the composed components and the required packages for the component to function properly.

Anatomy

import { Description, Label } from "@/components/ui/field"
import { Switch } from "@/components/ui/switch"
<>
  <Switch value="profileVisible">
    <Label>Public profile</Label>
    <Description>Allow others to see your profile.</Description>
  </Switch>
  <Switch value="searchEngineIndexing">
    <Label>Search engine indexing</Label>
    <Description>
      Allow search engines to index your profile.
    </Description>
  </Switch>
  <Switch defaultSelected value="twoFactor">
    <Label>Two-factor authentication</Label>
    <Description>
      Add an extra layer of security to your account.
    </Description>
  </Switch>
  <Switch value="activityStatus">
    <Label>Show activity status</Label>
    <Description>Let others see when you're online.</Description>
  </Switch>
</>

Description

You can add a description to the switch by passing the description prop or using the Description component.

Loading...

Controlled

You can manage the switch's state by setting the isSelected prop.

Loading...

Uncontrolled

You can also use the uncontrolled version of the switch.

Loading...

Disabled

A disabled switch cannot be toggled and is non-interactive.

Loading...
Flexible blocks and templates
Use ready-made blocks to craft unique pages without starting from scratch.
blocks.intentui.com
Switch / Intent UI