npx shadcn@4.23.1 add @goop/trail-buttonButton
FreeA button with words that runs an action, in several looks and sizes, for React and Tailwind CSS. Free, MIT.
What an agent sees
- ButtonIconA glyph in the button
- ButtonLabelThe button's words, where they carry a type of their own (the quiet rounded button's 450 weight, a sort control's grey words)
- ButtonEndThe button's trailing run — a glyph after the words (a sort arrow, an outward arrow) or a key hint
import { Button, ButtonIcon, ButtonLabel, ButtonEnd } from '@/components/ui/goop/button';
import { useState } from 'react';
function NoteActions({ save }: { save?: () => Promise<void> }) {
const [saving, setSaving] = useState(false);
return (
<>
<Button variant="ghost" size="md">
<ButtonIcon icon="plus" />
<ButtonLabel>Add</ButtonLabel>
</Button>
{/* the main action: 28 px on a wide screen, 48 px on a phone */}
<Button
loading={saving}
loadingLabel="Saving"
onClick={async () => {
setSaving(true);
try {
await save?.();
} finally {
setSaving(false);
}
}}
>
Save
</Button>
</>
);
}Switch every look, shape and size; change the words; add the icon; make it disabled or busy. Press it (pointer or keyboard) and the count under it goes up, but never while disabled or busy (busy keeps its width and the focus). Nothing is saved: the press is only counted.
When to use
- A button with words that runs an action, in several looks and sizes.
When not to use
- For an icon alone use IconButton, to delete DestructiveButton.
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 Button on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/trail-buttonAdd the Goop Button to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { Button, ButtonIcon, ButtonLabel, ButtonEnd } from '@/components/ui/goop/button';
import { useState } from 'react';
function NoteActions({ save }: { save?: () => Promise<void> }) {
const [saving, setSaving] = useState(false);
return (
<>
<Button variant="ghost" size="md">
<ButtonIcon icon="plus" />
<ButtonLabel>Add</ButtonLabel>
</Button>
{/* the main action: 28 px on a wide screen, 48 px on a phone */}
<Button
loading={saving}
loadingLabel="Saving"
onClick={async () => {
setSaving(true);
try {
await save?.();
} finally {
setSaving(false);
}
}}
>
Save
</Button>
</>
);
}- Fits: account, app, board, chat, flow, list, record, schedule, states (their recipes).
- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| variant | primary | outline | ghost | subtle | link | nav | text = primary | |
| shape | pill | rounded = pill | |
| size | sm | md | lg | xl = md | |
| asChild? | boolean = false | Render the button's look on the one child element instead of a button (a link, a menu's trigger). |
| loading? | boolean = false | The button's action is running: a spinner over its words (the width kept), and no press reaches onClick or submits; it keeps the focus. |
| loadingLabel? | string = 'Loading' | What a reader hears beside the button's words while loading. |
| type? | 'button' | 'submit' | 'reset' | |
| onClick? | (event: MouseEvent) => void | |
| disabled? | boolean |
| Part | What it is |
|---|---|
| ButtonIcon | A glyph in the button; icon: IconName — A pack icon name |
| ButtonLabel | The button's words, where they carry a type of their own (the quiet rounded button's 450 weight, a sort control's grey words); words without it sit in the button directly |
| ButtonEnd | The button's trailing run — a glyph after the words (a sort arrow, an outward arrow) or a key hint |
- Class recipes (cva): buttonVariants (Button)
- data-slot values (to select a part by): button, button-end, button-icon, button-label, button-spinner
Keyboard
| Key | What it does |
|---|---|
| Enter | Activate |
| Space | Activate |
Accessibility
- The native element answers the keyboard.
- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| expanded | the attribute data-state=open |
| open | the attribute data-state=open |
| disabled | the prop disabled |
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
Responsive behaviour
- The button is as wide as its words wherever it stands; no parent or prop stretches it. One that fills its row takes
className="w-full"; one that fills it on a phone only,className="max-narrow:w-full".
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.