Button

A pressable button built on Base UI's useRender, styled with class-variance-authority variants for seven visual variants, eight sizes, and three decorative appearances. It can render as a native button, or swap its element through the render prop or asChild.

Button
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @honestui/button

Requires @honestui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Button } from "@/components/ui/button"export function Example() {  return (    <Button variant="default" size="default" appearance="flat">      Save changes    </Button>  )}
  • Primary, secondary, and destructive actions in forms, dialogs, and toolbars
  • Icon-only controls such as close, more, or toolbar actions using the icon sizes
  • Navigation that should look like a button, by rendering an anchor via render or asChild
  • Decorative call-to-action buttons that need a glossy, glow, or bevel appearance

Examples

Variants

Renders each visual variant side by side.

variants.tsx
import { Button } from "@/components/ui/button"export function VariantsExample() {  return (    <div className="flex flex-wrap gap-2">      <Button variant="default">Default</Button>      <Button variant="secondary">Secondary</Button>      <Button variant="outline">Outline</Button>      <Button variant="ghost">Ghost</Button>      <Button variant="link">Link</Button>      <Button variant="destructive">Delete</Button>      <Button variant="destructive-outline">Remove</Button>    </div>  )}

Icon-only button

Icon sizes are square. Always provide an accessible name with aria-label because there is no visible text.

icon-only-button.tsx
import { X } from "lucide-react"import { Button } from "@/components/ui/button"export function CloseExample() {  return (    <Button variant="ghost" size="icon" aria-label="Close dialog">      <X />    </Button>  )}

Rendering as a link

Uses the render prop from Base UI to change the underlying element to an anchor while keeping button styling.

rendering-as-a-link.tsx
import { Button } from "@/components/ui/button"export function DocsLinkExample() {  return (    <Button render={<a href="/docs" />} variant="outline" appearance="glossy">      Read the docs    </Button>  )}

asChild with a single child

asChild passes the button styling to its single child element, such as a Next.js Link.

aschild-with-a-single-child.tsx
import Link from "next/link"import { Button } from "@/components/ui/button"export function AsChildExample() {  return (    <Button asChild size="lg" variant="default" appearance="bevel">      <Link href="/pricing">View pricing</Link>    </Button>  )}

API reference

PropTypeDefaultDescription
variant"default" | "outline" | "secondary" | "destructive" | "destructive-outline" | "ghost" | "link" | null | undefined"default"Visual style of the button, derived from buttonVariants.
size"default" | "xs" | "sm" | "lg" | "xl" | "icon" | "icon-sm" | "icon-lg" | null | undefined"default"Size and spacing scale. The icon, icon-sm, and icon-lg values are square icon-only sizes.
appearance"flat" | "glossy" | "glow" | "bevel" | null | undefined"flat"Decorative surface treatment. flat adds no extra classes; glossy adds a highlight, glow adds an inner rim light, and bevel adds a raised 3D edge that sinks on press.
asChildbooleanfalseWhen true, the single child element receives the button props and classes instead of a wrapping button. Children must be a single valid React element.
renderReact.ReactElement | ((props, state) => React.ReactElement) | undefined (from useRender.ComponentProps<"button">)—Base UI render prop that replaces the default button element. When set, the type attribute is not forced to button.
classNamestring | undefined—Additional classes merged with the variant classes through cn.
childrenReact.ReactNode—Button content. When asChild is true it must be a single element.
...propsOmit-compatible button element props (React.ComponentProps<"button"> via useRender)—All other native button attributes such as disabled, onClick, type, aria-label, and form props are forwarded to the rendered element.

Accessibility

  • Native button semantics are kept by default, and type="button" is set so the component does not submit forms unless type is overridden.
  • Icon-only sizes (icon, icon-sm, icon-lg) have no visible text, so provide aria-label or visually hidden text.
  • Focus is shown with focus-visible using the --hui-focus-ring outline with an accent offset, and keyboard focus is not removed by outline-none.
  • Disabled state uses the disabled attribute, which removes the button from the tab order and blocks interaction; the disabled style is also applied via the disabled selector.
  • When rendering as a link with render or asChild, the rendered element must keep correct link semantics, such as an href, and should not also be given role="button".
  • On coarse pointers an :after pseudo-element extends the hit area to at least 44px square (min-h-11 and min-w-11) to meet touch target guidance.
  • Motion uses motion-safe classes so transitions and the press scale are disabled for users who prefer reduced motion.
  • The destructive fill is darkened so white 13px text meets 4.5:1 contrast, as noted in the source comment.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Button" component (honestui/button) from its shadcn registry.1. Install it with: npx shadcn@latest add @honestui/button2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: variant, size, appearance, asChild, render, className, children, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Button } from "@/components/ui/button"export function Example() {  return (    <Button variant="default" size="default" appearance="flat">      Save changes    </Button>  )}```

Files & dependencies

  • button.tsx→ components/ui/button.tsx
dependencies@base-ui/reactclass-variance-authority

Looks similar, elsewhere