Fair Case

Button

A pill that does something on this page. Primary is the action fill; secondary is a rule border. For navigation that should read as a button, use ButtonLink, which shares these classes.

Examples

Primary, secondary, the small size and disabled.

TSX

// Button: a pill that does something on this page (send, start over). Use
// primary for the one main action in a view and secondary beside it. For a
// control that goes to another page, use ButtonLink instead.
import { Button } from "@repo/ui/button";

export default function ButtonExamples() {
  return (
    <>
      <Button>Ask a question</Button>
      <Button variant="secondary">Start over</Button>
      {/* sm is 40px tall, for a toolbar or the header. */}
      <Button size="sm">Send</Button>
      {/* Disabled dims to 40% and turns off the hover tones. */}
      <Button disabled>Send</Button>
    </>
  );
}

buttonVariants

The same classes as a function, for an element that is not a button.

TSX

// buttonVariants: the Button's classes as a function, for an element that is
// not a <button>, such as a plain link drawn before any script loads. For a
// link inside the app, prefer ButtonLink, which wraps this.
import { buttonVariants } from "@repo/ui/button";

// href is where the link goes; it defaults to the Join page.
export default function ButtonClasses({ href = "/join" }: { href?: string }) {
  return (
    <a
      href={href}
      className={buttonVariants({ variant: "secondary", size: "sm" })}
    >
      Join
    </a>
  );
}

Variants

Variants
PropValueHow it looks
variantprimaryAction fill with the on-accent text. On hover the fill becomes accent-hover.
variantsecondaryNo fill, a 1px rule border and the text colour. On hover the border becomes the accent and the fill becomes the hover tint.
basesharedInline flex, centred, a full pill (rounded-full), 8px gap, weight 500, text-base (16/24), no text selection.
sizemd44px tall at least, 24px side padding, 12px top and bottom.
sizesm40px tall at least, 20px side padding, 10px top and bottom.

States

States
StateHow it looks
restThe variant's own fill or border.
hoverPrimary: accent-hover fill. Secondary: accent border and hover tint. Colour changes ease over 300ms (transition-tone); nothing moves.
pressednot written
focusThe global keyboard focus ring: 2px in the focus colour, 2px off the edge, following the pill.
disabled40% opacity (opacity-disabled) and a not-allowed cursor. Hover tones are off while it is disabled.

Props

Import from @repo/ui/button.

Props
PropTypeDefaultWhat it does
variant"primary" | "secondary"default "primary"The action fill, or a rule border that tints on hover.
size"md" | "sm"default "md"md is 44px tall with 24px sides; sm is 40px with 20px.
classNamestringJoined with cn(), so a caller's class overrides a default.
disabledbooleandefault false40% opacity and a not-allowed cursor. From Base UI's button.
...Base UI button propsEvery other prop of Base UI's button, such as type and onClick.

Use it well

  • Colour changes ease; nothing moves.

  • The header's Ask a question is ButtonLink at size sm.

  • The label is the accessible name. Keep it a short verb.

  • Do: Use ButtonLink when the control goes to another page, and Button for what happens on this one.

  • Don't: Put a link inside a Button, or a button inside a link. Use ButtonLink.