Skip to Content
Getting startedFoundationsComponentsPackagesTools

Button

The one button: four weights, five tones, three sizes, and a link when given an href.

Examples

Playground

Variant

Visual weight, from most to least emphasis. Weight only: meaning is `tone`.

primary
secondary
ghost
text

Tone

What the action means. Every tone works at every variant (see Tone × Variant).

neutral
info
success
warning
error

Size

sm is 28px for dense pointer UI, md 36px is the default, lg 44px is the AAA target size.

sm
md
lg

States

Every state side by side. Hover, focus and pressed are forced, so they can be reviewed without a pointer. Loading keeps the width of the rest state.

rest
hover
focus
pressed
loading
disabled

Content

A long label stays on one line, and the external glyph follows any label.

long label
external

As a link

A disabled anchor has no `href`, `tabindex="-1"` and no `target`. `aria-disabled` alone announces a state without creating one: the link stayed focusable and still navigated.

disabled linkUnavailable

Tone by variant

Every combination, because the point is that every cell works. A tone remaps custom properties and decides nothing about weight; a variant reads the ones it needs and decides nothing about meaning.

primarysecondaryghosttextneutral
info
success
warning
error

Install

npx shadcn add @hipuku/button

Usage

import { Button } from '@/components/haus/components/Button'

<Button variant="primary" onClick={save}>
  Save changes
</Button>

API

Button also takes its element's own attributes and forwards its ref. className lands on the root.

PropTypeDescription
variant"primary" | "secondary" | "ghost" | "text"
tone"neutral" | "info" | "success" | "warning" | "error"What it means. error is what variant="danger" used to say.
size"sm" | "md" | "lg"
externalbooleanOpens elsewhere: appends the glyph and, with href, is the honest signal that the destination leaves this app. Behaviour, so not a variant.
asChildfalse
loadingboolean
hrefstringRenders as an anchor when provided
targetstring

Variants

variant is visual weight. Use one primary per view, for the action the view is for.

variantUse it for
primaryThe main action
secondaryActions beside the main one
ghostQuiet actions in toolbars and dense rows
textAn action that sits in a line of text

Tones

tone is meaning, separate from weight, and every tone works at every variant: neutral, info, success, warning and error. Use error for an action that destroys something.

Sizes

md is the default. sm is for dense interfaces, and lg meets the enhanced touch target size.

Give it href and it renders an <a>. Add external for a destination outside the app: it adds an arrow, and a _blank target gets rel="noopener noreferrer".

For a router's link, pass it as the single child with asChild:

<Button asChild variant="secondary">
  <Link href="/settings">Settings</Link>
</Button>

Loading

loading shows a spinner in place of the label. The button keeps its width and its focus, and it does not run onClick or submit its form a second time while it loads.

loading cannot be combined with asChild, and that is a type error: a link has no submitting state to show.

Accessibility

  • A <button>, or an <a> with href, so it works from the keyboard as itself: Enter and Space, or Enter on a link.
  • The focus outline shows on keyboard focus only, and meets the 3:1 contrast WCAG asks of it.
  • A disabled link is really disabled: out of the tab order and not activatable.

loading sets aria-busy, which marks the button as busy but does not make a screen reader say anything. If the wait has to be announced, put its text in a live region you own.

On this page