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

Toggle button

Free

A button that stays pressed until it is pressed again, for React and Tailwind CSS. Free, MIT.

Press it to hold it down, press again to let it up; switch every look and size, words or icon, and disable it. No notes are filtered: the line under it only says the state.

When to use

  • A button that stays pressed until it is pressed again.
  • Also called: toggle.

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 Toggle button 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-toggle-button
PROMPT
Add the Goop Toggle button to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { ToggleButton, ToggleButtonIcon } from '@/components/ui/goop/toggle-button';

function NotesViewToggle({ grouped, onGrouped }: { grouped: boolean; onGrouped: (next: boolean) => void }) {
  return (
    <div className="flex items-center gap-1">
      <ToggleButton aria-label="Group into lists" pressed={grouped} onPressedChange={onGrouped}>
        <ToggleButtonIcon icon="text-align-justify" />
      </ToggleButton>
      <ToggleButton variant="muted" aria-label="Starred notes only" defaultPressed>
        <ToggleButtonIcon icon="star" />
      </ToggleButton>
      <ToggleButton variant="chip">Due date</ToggleButton>
    </div>
  );
}
  • Fits: record, chat: toolbar.
  • Also known as: Toggle.
  • height, width, padding, gap, corner, background, shadow, text, motion: add no class for these.

API reference

Options
OptionTypeWhat it does
variantdefault | muted | chip | outline = default
sizemd | lg = md
shapepill | circle = pill
asChild?boolean
pressed?boolean
defaultPressed?boolean = false
onPressedChange?(pressed: boolean) => void
disabled?boolean
  • State: pressed (pressed / defaultPressed / onPressedChange)
Parts
PartWhat it is
ToggleButtonIconThe toggle's icon; icon: IconName — A pack icon name; pressedIcon?: IconName — The pack icon drawn instead while the toggle is pressed; none by default
  • Class recipes (cva): toggleButtonVariants (ToggleButton)
  • data-slot values (to select a part by): toggle-button, toggle-button-icon

Keyboard

KeyWhat it does
EnterToggle
SpaceToggle

Accessibility

  • The behaviour layer under the part answers keys, focus and dismissal: never write your own.
  • hover, active, focus, focus-visible: the browser's own (:hover, :active, :focus, :focus-visible): write nothing

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

StateDrawn by
pressedthe attribute aria-pressed
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/toggle-button.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add @goop/meadow-toggle-button

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.