Skip to content
Haze UI

Button

Button or link styled as a button, in seven variants and three text sizes, plus a square icon size and press and loading states.

pnpm dlx shadcn@latest add @haze/button
Open preview in a new tab
Liveno JavaScript

When to use

  • Any action or navigation that should look like a button
  • Pass href to render a real link; omit it for a <button>

When not to use

  • Navigation inside running text; use a plain underlined link

Installation

Add the Haze registry to components.json once, then install Button with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/button
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
hrefstring–Renders an <a> when set, otherwise a <button>.
variant"primary" | "secondary" | "outline" | "ghost" | "soft" | "link" | "destructive""primary"Visual style. soft is a muted fill for a secondary call to action.
size"sm" | "md" | "lg" | "icon""md"Height 32, 36 or 44 px; icon is a 36 px square for one icon plus an aria-label.
type"button" | "submit" | "reset""button"Button type when no href is set.
loadingbooleanfalseReplaces the label with a spinner, disables the button and sets aria-busy. The button keeps its width. Applies to <button> only, not to links.
classstring–Extra classes, merged with tailwind-merge.
...attributesHTML button or anchor attributes–Anything else is passed to the rendered <button> or <a>: aria-label, disabled, form, command, commandfor, popovertarget and so on. The dialog, drawer, popover and dropdown menu rely on this.

Keyboard interactions

EnterSpace
Activate (Space only for <button>)

Accessibility

  • Chooses <a> or <button> from href, so the semantics match the behaviour.
  • A loading button is disabled, so it takes no clicks or focus. Its label stays in the DOM (hidden from sight) so the accessible name does not change, and aria-busy="true" tells assistive technology it is working.
  • Pressing a button scales it to 97% for 75 ms. The motion is switched off under prefers-reduced-motion.
  • The visible focus ring uses --ring at 3:1 or better; the smallest size is still 32 px tall.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Button" with `npx shadcn@latest add @haze/button`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Button from "@/components/haze/ui/button.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/button.md

  • Customize with real content

    Adapt the Haze button ui for our product. Replace the demo values of these props with our real content: href, variant, size, type, loading, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: Chooses <a> or <button> from href, so the semantics match the behaviour. A loading button is disabled, so it takes no clicks or focus. Its label stays in the DOM (hidden from sight) so the accessible name does not change, and aria-busy="true" tells assistive technology it is working. Pressing a button scales it to 97% for 75 ms. The motion is switched off under prefers-reduced-motion. The visible focus ring uses --ring at 3:1 or better; the smallest size is still 32 px tall. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using button, check it fits: use it when any action or navigation that should look like a button; pass href to render a real link; omit it for a <button>. Avoid it when navigation inside running text; use a plain underlined link. Alternatives: @haze/badge.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog