compacto-ui

Search documentation

Jump to a page or a component.

Button

Six roles, eight sizes, a 1px press settle and no elevation.

server-safe

Preview

Installation

No install — ask an AI agent to copy this component from registry.json.

import { Button, buttonVariants } from "@/components/ui/button";

Notes

  • Server-safe — renders in a Server Component without opening a client boundary.
  • The rest state carries a transparent 1px border, so hover and focus never shift layout. That is also what lets ButtonGroup collapse the seam between buttons.
  • destructive is a tint, not a solid red block. A toolbar with one filled red bar reads as an error state rather than an option.
  • aria-expanded holds the hover fill while a menu the button opens is showing.
  • The icon* sizes render no text, so they need an aria-label.

Props

The props worth knowing. Everything else passes straight through to the underlying element, including className, which is merged last so it always wins.

PropTypeDefaultDescription
variant"default" | "outline" | "secondary" | "ghost" | "destructive" | "link""default"Visual role.
size"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg""default"Geometry. The icon sizes are square hit areas for a lone glyph.
asChildbooleanfalseRender the caller's child element instead of a <button>, keeping these styles.