Toggles essentials
Styled toggle switches from the ai2 free styled layer: five decorative variants (IOSToggle, SquareToggle, IconToggle, GlowToggle, LabeledToggle) built on ai2 design tokens with framer-motion thumb animation. Each renders a role="switch" button that works uncontrolled or controlled.


Installed with shadcn add · 2 workarounds · theme from registry.json
- applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
- installed base item https://ai2.design/r/tokens.json (registry preview settings)
Installation
Requires @ai2 in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { IOSToggle, SquareToggle, IconToggle, GlowToggle, LabeledToggle } from "@/components/ui/toggles-styled"export function Example() { return <IOSToggle defaultChecked aria-label="Airplane mode" />}- Binary on/off settings in forms, dashboards, or settings panels that need a styled, token-driven switch
- Theme or mode switches where the icon variant (sun/moon) communicates state
- Feature flags or promotional toggles that benefit from the glow highlight
- Settings rows where an explicit ON/OFF text label improves clarity
Examples
Uncontrolled iOS toggle
Starts on via defaultChecked and manages its own state.
import { IOSToggle } from "@/components/ui/toggles-styled"export default function Demo() { return <IOSToggle defaultChecked aria-label="Enable sync" />}Controlled glow toggle
Keeps state in the parent and reacts through onCheckedChange.
import { useState } from "react"import { GlowToggle } from "@/components/ui/toggles-styled"export default function NotificationSetting() { const [enabled, setEnabled] = useState(false) return ( <GlowToggle size="lg" checked={enabled} onCheckedChange={setEnabled} aria-label="Enable notifications" /> )}Icon and square sizes
Theme-style icon toggle next to a square beta toggle at different sizes.
import { IconToggle, SquareToggle } from "@/components/ui/toggles-styled"export function ThemeSwitch() { return ( <div className="flex items-center gap-4"> <IconToggle size="sm" aria-label="Toggle dark mode" /> <SquareToggle size="xl" defaultChecked aria-label="Enable beta" /> </div> )}Labeled toggle in a settings row
Shows visible ON/OFF text inside the track.
import { LabeledToggle } from "@/components/ui/toggles-styled"export function WifiRow() { return ( <div className="flex items-center justify-between"> <span>Wi-Fi</span> <LabeledToggle defaultChecked aria-label="Wi-Fi" /> </div> )}API reference
Accessibility
- Each toggle renders a button with role="switch" and aria-checked reflecting the current state.
- Native button semantics provide keyboard activation with Space and Enter.
- Provide an accessible name with aria-label or a associated visible label, since the icon and thumb variants have no text of their own.
- LabeledToggle exposes visible ON/OFF text, which supports users who cannot distinguish color.
- A visible focus ring (focus-visible:ring-[3px]) is shown on keyboard focus.
- Under prefers-reduced-motion, thumb movement is instant (duration 0) instead of animated.
- Disabled state uses the disabled attribute with reduced opacity and not-allowed cursor.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Toggles essentials" component (ai2/toggles-styled) from its shadcn registry.1. Install it with: npx shadcn@latest add @ai2/toggles-styled2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, checked, defaultChecked, onCheckedChange, className, ...rest.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { IOSToggle, SquareToggle, IconToggle, GlowToggle, LabeledToggle } from "@/components/ui/toggles-styled"export function Example() { return <IOSToggle defaultChecked aria-label="Airplane mode" />}```Files & dependencies
- registry/ai2/styled/toggles-styled.tsx→ components/ui/toggles-styled.tsx