bysages

Switch

Forms

About

An accessible on/off toggle control built on Ark UI's headless switch machine, styled with CSS custom-property design tokens for light/dark themes.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Switch to your project and fits it to your theme.

Code

How Switch is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { Switch } from "@/components/ui/switch";

export default function SwitchContextDemo() {
  return (
    <Switch.Root style={{ maxWidth: "20rem" }}>
      <Switch.Control>
        <Switch.Thumb />
      </Switch.Control>
      <Switch.Context>
        {(ctx: { checked: boolean }) => (
          <Switch.Label>
            Overlays are {ctx.checked ? "dissolving" : "sharp"}
          </Switch.Label>
        )}
      </Switch.Context>
      <Switch.HiddenInput />
    </Switch.Root>
  );
}

Dependencies

More by bysages

View all
  • Avatar Group

    Avatar Group

    14
  • Typography

    Typography

    12
  • Spinner

    Spinner

    7
  • Block UI

    Block UI

    2
  • Clipboard

    Clipboard

  • Rating Group

    Rating Group

  • Date Input

    Date Input

  • Grid

    Grid

More in Forms

View all
  • Premium Auth

    Premium Auth

    593
  • Contact Form

    Contact Form

    28
  • Form

    Form

    4
  • Login 1

    Login 1

    70
  • Book A Demo 1

    Book A Demo 1

    94
  • Contact Card

    Contact Card

    1.1K
  • HeroUI Field Error

    HeroUI Field Error

    13
  • Form [react-aria-components]

    Form [react-aria-components]

    19