Skip to Content
ComponentsButton

Button

A native <button> with full interactive state tracking. Use asChild to render as any element while keeping all behaviour and data attributes.

Preview

Anatomy

import { Button } from '@wire-ui/react' <Button>Click me</Button> // Polymorphic — renders as an anchor <Button asChild> <a href="/dashboard">Go to dashboard</a> </Button>

Props

PropTypeDefaultDescription
asChildbooleanfalseMerge all props onto the immediate child element
disabledbooleanfalseDisables the button; adds data-disabled
autoFocusbooleanfalseAuto-focuses on mount; adds data-autofocus
type'button' | 'submit' | 'reset''button'Native button type (ignored when asChild)
...restButtonHTMLAttributesAll standard HTML button attributes

Data attributes

AttributeWhen present
data-hoverMouse is over the button
data-focus-visibleButton has keyboard focus
data-activeButton is being pressed
data-disableddisabled prop is true
data-autofocusautoFocus prop is true

asChild

asChild merges all props (including data-* attributes and event handlers) onto the child element. The child must be a single React element.

// Renders as <a> with all Button data attributes and handlers <Button asChild> <a href="/profile">View profile</a> </Button> // Works with custom components too <Button asChild> <Link to="/dashboard">Dashboard</Link> </Button>

Accessibility

  • Renders as <button> by default — correct semantics and keyboard behaviour out of the box.
  • type="button" prevents accidental form submission.
  • data-focus-visible uses element.matches(':focus-visible') — only keyboard navigation triggers it, not mouse clicks.
Last updated on

MIT License © 2026 wire-ui