Fair Case

ButtonLink

The button's classes and its link form, kept apart from Base UI's button so a page with only the link loads none of it. The site header's "Ask a question" is this link.

Variants and sizes

The same classes on a button and on a link. Only the button has a disabled state.

md
md
sm
sm
Button, disabled
Link styled as a button
ButtonLink, an anchor

TSX

// ButtonLink and Button: the same classes on a link and on a button. Use
// ButtonLink when the control goes to another page and Button for what
// happens on this one. Only the button has a disabled state.
import { Button } from "@repo/ui/button";
import { ButtonLink } from "@repo/ui/button-link";

// href is where the link goes; it defaults to the Join page.
export default function ButtonLinkVariants({
  href = "/join",
}: {
  href?: string;
}) {
  return (
    <>
      <Button>Primary</Button>
      <Button variant="secondary">Secondary</Button>
      <Button size="sm">Small primary</Button>
      <Button variant="secondary" size="sm">
        Small secondary
      </Button>
      <Button disabled>Disabled</Button>
      {/* An anchor: it navigates, so it takes href and has no disabled state. */}
      <ButtonLink href={href} variant="secondary">
        Link styled as a button
      </ButtonLink>
    </>
  );
}

Hover

Colour changes ease over 300ms; nothing moves. Drawn here with the hover classes pinned on the element.

primary, hover
secondary, hover

TSX

// The two button variants, for their hover tones. Hover is the component's
// own: primary eases to the accent-hover fill, secondary to the accent border
// and the hover tint, over 300ms, and nothing moves. Write no hover classes.
import { Button } from "@repo/ui/button";

export default function ButtonHover() {
  return (
    <>
      <Button>Primary</Button>
      <Button variant="secondary">Secondary</Button>
    </>
  );
}

Code

TSX

// ButtonLink: a link that looks like a button, for a control that goes to
// another page. It is an anchor, not Base UI's button, so a page with only the
// link loads none of the button's code. The site header's "Ask a question" is
// one, at size sm.
import { ButtonLink } from "@repo/ui/button-link";

export default function ButtonLinkUsage() {
  return (
    <ButtonLink href="/join" variant="secondary">
      Link styled as a button
    </ButtonLink>
  );
}

The header's call is <ButtonLink size="sm" className="col-start-1 row-start-1" href={...}> (site-header.tsx). The real button is Button from @repo/ui/button; both share buttonVariants.

Variants

Variants
PropValueHow it looks
variantprimaryAccent fill (#0E6FD6 light, #7EB7FF dark), on-accent text (#FAFDFF light, #00172E dark). Hover: accent-hover fill (#143D8D light, #B2D5FF dark).
variantsecondary1px rule border (#B2D5FF light, #23446A dark), text colour. Hover: border turns accent (#0E6FD6 light, #7EB7FF dark) and the tint fill appears (#EEF6FF light, #122A43 dark).
sizemdMin height 44px, 24px side and 12px top and bottom padding, text-base 16/24.
sizesmMin height 40px, 20px side and 10px top and bottom padding, text-base 16/24.
basesharedFull pill (rounded-full), 8px gap, weight 500, content centred, no text selection. Colour changes ease over 300ms; nothing moves.

States

States
StateHow it looks
restAs the variant describes.
hoverPrimary deepens to accent-hover. Secondary gets the accent border and the tint fill. Not applied while disabled.
focusThe global 2px focus ring with a 2px gap.
disabledButton only (data-disabled): opacity 40%, not-allowed cursor, no hover. The link form is an anchor and has no disabled state.
pressednot written

Props

Import from @repo/ui/button-link.

Props
PropTypeDefaultWhat it does
variant"primary" | "secondary"default "primary"Primary is the action fill. Secondary is a rule border.
size"md" | "sm"default "md"md is 44px tall, sm is 40px tall.
classNamestringMerged with cn(). Join's form adds min-h-13 w-full font-semibold.
...restComponentProps<"a">href, children and the other anchor props (ButtonLink).
ButtonBase UI Button props minus className, plus variant and sizeThe same look on a real button, from @repo/ui/button, which also re-exports ButtonLink and buttonVariants.
buttonVariantscva functionExported so another element can wear the same classes (the header's invisible sizer, Join's submit button).

Use it well

  • Use ButtonLink for navigation that reads as a button. Use Button for an action.

  • Import from @repo/ui/button-link on a page that needs only the link, so none of Base UI's button loads.

  • Colour changes ease and nothing moves, so there is no lift or scale on hover.

  • Join's form passes buttonVariants() to its own submit element and adds min-h-13 w-full font-semibold, rather than redrawing the button.