GitHub
Core
Glass
Brutal
Humanist

Toggle

Toggle switches are used for binary on/off settings. They provide immediate visual feedback and support controlled/uncontrolled modes.

Toggle Container Playground

Toggle Container Playground
Preview
Code
Email notificationsReceive updates about your account
Controls
Size:
Small
Medium
Large
Style:
Default
Pill
Supporting:
Disabled:

Toggle Label Playground

Toggle Label Playground
Preview
Code
Dark modeEnable dark theme across the app
Controls
Size:
Small
Medium
Large
Style:
Default
Pill
Supporting:
Disabled:

Toggle Playground

Toggle Playground
Preview
Code
Controls
Style:
Default
Pill
Size:
Small
Medium
Large
Disabled:

Installation

You can add the toggle component to your project manually:

1

Install the following dependencies:

npm install @react-aria/focus @react-aria/interactions @react-aria/utils
2

Copy and paste the following code into your project.

Loading source code...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { Toggle } from '@versaui/ui/components/Toggle';

// Basic toggle
<Toggle />

// Controlled toggle
<Toggle checked={isOn} onChange={setIsOn} />

Styles

Two styles are available — default and pill:

<Toggle style="default" />
<Toggle style="pill" />

Sizes

Three sizes — small, medium, and large:

<Toggle size="large" />
<Toggle size="medium" />
<Toggle size="small" />

Toggle with Label

Use ToggleLabel to pair a toggle with a label and optional supporting text:

import { ToggleLabel } from '@versaui/ui/components/Toggle';

<ToggleLabel
  label="Dark mode"
  supportingText="Enable dark theme across the app"
/>

Toggle Container

Use ToggleContainer for a boxed layout with title and description:

import { ToggleContainer } from '@versaui/ui/components/Toggle';

<ToggleContainer
  title="Email notifications"
  supportingText="Receive updates about your account"
/>

Disabled

<Toggle disabled />
<ToggleLabel label="Disabled" disabled />
<ToggleContainer title="Disabled" disabled />

Accessibility

  • Uses role="switch" with proper aria-checked
  • Keyboard operable with Space to toggle
  • Focus ring visible on keyboard focus
  • Label association for screen readers

ToggleContainer Props

PropTypeDefaultDescription
titlestring-Container title text.
supportingTextstring-Description text below title.
size'large' | 'medium' | 'small''medium'Toggle size.
toggleStyle'default' | 'pill''default'Toggle shape style.
checkedbooleanfalseControlled checked state.
disabledbooleanfalsePrevents interaction.
onChange(checked: boolean) => void-Called when toggle state changes.

ToggleLabel Props

PropTypeDefaultDescription
labelstring-Label text next to toggle.
supportingTextstring-Helper text below the label.
size'large' | 'medium' | 'small''medium'Toggle size.
toggleStyle'default' | 'pill''default'Toggle shape style.
checkedbooleanfalseControlled checked state.
disabledbooleanfalsePrevents interaction.
onChange(checked: boolean) => void-Called when toggle state changes.

Toggle Props

PropTypeDefaultDescription
style'default' | 'pill''default'Toggle shape style.
size'large' | 'medium' | 'small''large'Toggle size.
checkedbooleanfalseControlled checked state.
disabledbooleanfalsePrevents interaction.
onChange(checked: boolean) => void-Called when toggle state changes.

On this page