Tessera UI

Switch

A toggle control that allows users to turn a setting on or off

Installation

pnpm add @tessinaui/ui

Usage

import { Switch } from "@tessinaui/ui";
<Switch label="Enable notifications" defaultChecked />

Playground

Configure every property of the Switch component interactively:

Preview
Loading...

Showcase

All sizes, states, and label combinations:

Preview
Loading...

API Reference

Props

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"Size of the switch
checkedbooleanControlled checked state
defaultCheckedbooleanfalseUncontrolled default state
onCheckedChange(checked: boolean) => voidCalled when checked state changes
disabledbooleanfalseDisables the switch
labelstringLabel text displayed next to the switch
descriptionstringSupporting description text below the label
labelPosition"left" | "right""right"Side of the switch the label appears on
showIconbooleantrueShow checkmark icon in the knob when on

Sizes

Three sizes are available:

  • sm — Compact (20px × 36px track)
  • md — Default (32px × 64px track, matches Figma design)
  • lg — Large (36px × 72px track)

States

StateDescription
OffDefault unchecked state
OnChecked state with success color and checkmark
Disabled offGreyed out, non-interactive
Disabled onChecked but non-interactive
FocusVisible focus ring for keyboard navigation

Accessibility

The Switch component:

  • Uses Radix UI's Switch primitive for full accessibility
  • Role: switch with aria-checked state
  • Keyboard: Space to toggle, Tab to focus
  • Label is associated via htmlFor / id
  • Includes visible focus-visible ring (WCAG 2.1 AA)
  • Touch target meets 44×44px minimum on all sizes
  • Disabled state communicated via aria-disabled

On this page