Skip to main content

Common Examples

To use the Button, import it from @servicetitan/anvil2-ai-kit and pass a required label. The kit forbids children; all content flows through typed props.

Variants

The variant prop sets visual intent. Use "primary" for the main action, "secondary" for supporting actions, "ghost" for low-emphasis actions, and "danger" for destructive work.

Sizes

The size prop sets the target size. "medium" is the default. On touch devices, "xsmall" promotes to a 40×40 minimum so the tap target meets WCAG 2.5.5 guidance.

Icons

Pass a bare icon element for an icon-only button. Pair { icon, position } with the visible label to place an icon before or after the text. Import icons from @servicetitan/anvil2-icons.Icon-only buttons apply label as aria-label and show it in a presentational tooltip, so pointer and assistive-technology users share the same name.

Disabled

Set isDisabled to prevent press and hover while keeping the control focusable for keyboard users.

Press handling

Prefer onPress over onClick. onPress fires for click, touch, and Space/Enter, matching React Aria’s press semantics.

React Accessibility

  • Every Button requires a label, which is always the accessible name.
  • Icon-only buttons expose that name through aria-label and a presentational tooltip so screen readers do not announce the name twice.
  • Disabled buttons remain in the tab order. They do not activate.
  • Users activate a focused button with Enter or Space.
Last modified on August 28, 2026