๐ŸŽฏ Nexus teaches Next.js from foundations to professional systemsโ€ขโšก App Router, React 19, and Tailwind v4 in one learning pathโ€ข๐Ÿงฉ Inspect real components, layouts, and reusable patternsโ€ข๐Ÿ› ๏ธ Build production discipline, not just polished demosโ€ข๐Ÿ“š Tracks, references, and design studies in one placeโ€ข๐ŸŽฏ Nexus teaches Next.js from foundations to professional systemsโ€ขโšก App Router, React 19, and Tailwind v4 in one learning pathโ€ข๐Ÿงฉ Inspect real components, layouts, and reusable patternsโ€ข๐Ÿ› ๏ธ Build production discipline, not just polished demosโ€ข๐Ÿ“š Tracks, references, and design studies in one placeโ€ข๐ŸŽฏ Nexus teaches Next.js from foundations to professional systemsโ€ขโšก App Router, React 19, and Tailwind v4 in one learning pathโ€ข๐Ÿงฉ Inspect real components, layouts, and reusable patternsโ€ข๐Ÿ› ๏ธ Build production discipline, not just polished demosโ€ข๐Ÿ“š Tracks, references, and design studies in one placeโ€ข๐ŸŽฏ Nexus teaches Next.js from foundations to professional systemsโ€ขโšก App Router, React 19, and Tailwind v4 in one learning pathโ€ข๐Ÿงฉ Inspect real components, layouts, and reusable patternsโ€ข๐Ÿ› ๏ธ Build production discipline, not just polished demosโ€ข๐Ÿ“š Tracks, references, and design studies in one placeโ€ข
UI Components

Switch

An accessible toggle switch supporting controlled, uncontrolled, and labeled modes

Quick Preview

Structure

Anatomy of the Switch โ€” a track with a sliding thumb and an optional label.

TrackThumb
label (optional)
Track โ€” teal when on, gray when offThumb โ€” slides on toggleLabel + description โ€” optional

States

Click any switch to toggle it โ€” all state transitions are live.

Switch โ€” all states

Click to toggle; disabled switches cannot be interacted with

4 states

Off

Default ยท unchecked

On

Checked ยท click to try

Disabled off

Cannot interact

Disabled on

Locked in on state

Sizes

Three size tokens โ€” sm md (default) lg.

Sizes โ€” sm / md / lg

Toggle each switch to compare thumb and track dimensions

3 states

Small โ€” sm

w-8 h-4 ยท compact

Medium โ€” md

w-11 h-6 ยท default

Large โ€” lg

w-14 h-7 ยท spacious

Installation

// Copy the Switch component from
src/components/ui/Switch.tsx

Usage

'use client'
import { Switch } from '@/components/ui/Switch'
// Uncontrolled
<Switch label="Dark mode" />
// Controlled
const [enabled, setEnabled] = useState(false)
<Switch checked={enabled} onChange={setEnabled} label="Dark mode" />

Examples

With Description

Sizes

Settings List

Prompt Preview

Copy a prompt that recreates this UI

Paste this into your AI coding assistant to generate code that closely matches the reference, including color, size, shape, typography, spacing, and polish.

Copy-ready AI prompt

Starts from the current visual reference and project constraints.

Tweak only product-specific copy or data after the first generation pass.

Props

PropTypeDefaultDescription
checkedboolean-Controlled checked state
defaultCheckedboolean-Initial state for uncontrolled mode
onChange(checked: boolean) => void-Callback fired on toggle
labelstring-Label text next to the switch
descriptionstring-Secondary description below label
size"sm" | "md" | "lg""md"Switch size
disabledboolean-Disable the switch

Features

  • โœ“Controlled and uncontrolled modes
  • โœ“role="switch" + aria-checked for accessibility
  • โœ“Label and description slots
  • โœ“Three sizes (sm, md, lg)
  • โœ“Primary color when checked
  • โœ“focus-visible ring
  • โœ“Client Component