Trigger an action or event, such as saving a memory or opening a dialog.
The default variant is normal, the solid inverted button. Every button is square, 36px tall and has a 1px stroke or fill.
import { Button } from "@/purpose/components/ui/button";
<Button>Connect agent</Button>
<Button variant="secondary">Manage</Button>
<Button variant="gray">Copy link</Button>
<Button variant="ghost">Cancel</Button>
<Button variant="success">Add memory</Button>
<Button variant="destructive">Delete key</Button>The default height is 36px. A taller one (48px, h-12) is used on the phone menu, and the sidebar's Upgrade is 32px.
<Button className="h-8">Save</Button> {/* 32px: Upgrade in the sidebar */}
<Button>Save</Button> {/* 36px: the default */}
<Button className="h-12 text-[15px]">Save</Button> {/* 48px: the phone menu */}Icon-only buttons are 36px squares with a filled icon. They need an aria-label that names the action and its target. There are no rounded or circular buttons.
<Button variant="secondary" className="w-9 px-0" aria-label="Open menu"><ListIcon weight="fill" /></Button>
<Button variant="secondary" className="w-9 px-0" aria-label="Copy link"><CopyIcon weight="fill" /></Button>
<Button variant="gray" className="w-9 px-0" aria-label="Settings"><GearSixIcon weight="fill" /></Button>
<Button variant="ghost" className="w-9 px-0" aria-label="Delete key"><TrashIcon weight="fill" /></Button>
<Button variant="secondary" className="w-9 px-0" aria-label="Close"><XIcon weight="fill" /></Button>A utility button (Invite teammate, Manage, Copy link, Filter) has a filled icon before its text. An action button (Connect agent, Add memory, Approve, Cancel) has no icon. There is no suffix icon and no arrow.
<Button variant="secondary"><PlusIcon aria-hidden="true" weight="fill" />Invite teammate</Button>
<Button variant="secondary"><GearSixIcon aria-hidden="true" weight="fill" />Manage</Button>
<Button variant="gray"><CopyIcon aria-hidden="true" weight="fill" />Copy link</Button>Loading is always a spinner. Put the small Spinner before the label and disable the button until the work ends.
import { Spinner } from "@/purpose/registry/spell-ui/spinner";
<Button disabled><Spinner size="sm" />Saving…</Button>
<Button variant="secondary" disabled><Spinner size="sm" />Saving…</Button>
<Button variant="gray" disabled><Spinner size="sm" />Saving…</Button>Disable a button only when the action is impossible right now, such as a dialog's main action until its required input exists.
<Button disabled>Connect agent</Button>
<Button variant="secondary" disabled>Manage</Button>
<Button variant="gray" disabled>Copy link</Button>
<Button variant="ghost" disabled>Cancel</Button>
<Button variant="success" disabled>Add memory</Button>
<Button variant="destructive" disabled>Delete key</Button>Use buttonVariants on a Link for navigation that changes the URL. Wrap it in cn() so the variant's colours win over the base. It takes the same variants. A link that leaves the site just opens in a new tab.
import Link from "next/link";
import { buttonVariants } from "@/purpose/components/ui/button";
import { cn } from "@/lib/utils";
<Link href="/start?intent=personal" className={cn(buttonVariants({ variant: "normal" }))}>Get started</Link>
<Link href="/sign-in" className={cn(buttonVariants({ variant: "gray" }))}>Sign in</Link>
<Link href="/docs" className={cn(buttonVariants({ variant: "secondary" }))}>Docs</Link>