Theme
Install with your agentnpx shadcn@4.23.1 add @goop/meadow-switch

Switch

Free

An on/off control for a setting that takes effect at once, for React and Tailwind CSS. Free, MIT.

Press the switch (or Space on it) to turn the digest on and off; switch its size and disable it from the panel. Nothing is saved: the switch only says its state.

When to use

  • An on/off control for a setting that takes effect at once.
  • Also called: toggle.

When not to use

  • For a choice saved with a form use Checkbox.

Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Switch on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

Terminal
npx shadcn@4.23.1 add @goop/meadow-switch
PROMPT
Add the Goop Switch to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { Switch } from '@/components/ui/goop/switch';

function NotificationSettings({ digest, onDigest }: { digest: boolean; onDigest: (on: boolean) => void }) {
  return (
    <div className="flex flex-col gap-4">
      <div className="flex items-center justify-between gap-4">
        <label htmlFor="weekly-digest" className="text-base">
          Weekly digest of the Fieldwork notes
        </label>
        <Switch id="weekly-digest" checked={digest} onCheckedChange={onDigest} />
      </div>
      <div className="flex items-center justify-between gap-4">
        <label htmlFor="visit-reminders" className="text-base">
          Remind me the day before a site visit
        </label>
        <Switch id="visit-reminders" name="reminders" defaultChecked />
      </div>
    </div>
  );
}
  • Fits: flow, settings (their recipes).
  • height, width, corner, background, shadow, motion: add no class for these.

API reference

Options
OptionTypeWhat it does
sizemd | sm | xs = md
onCheckedChange?(checked: boolean) => voidCalled after onChange with the switch's new state.
checked?boolean
defaultChecked?boolean
onChange?(event: ChangeEvent<HTMLInputElement>) => void
value?string
name?string
required?boolean
disabled?boolean
form?string
  • State: checked (checked / defaultChecked / onCheckedChange)
  • Class recipes (cva): switchVariants (Switch)
  • data-slot values (to select a part by): switch

Keyboard

KeyWhat it does
SpaceToggle

Accessibility

  • The native element answers the keyboard.
  • hover, active, focus-visible, checked: the browser's own (:hover, :active, :focus-visible, :checked): write nothing

Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:

StateDrawn by
disabledthe prop disabled

Motion

  • The part sets its own motion: add no transition or animation of your own.

Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

goop.so/themes/meadow/components/switch.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add @goop/meadow-switch

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.