useButton

Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions, focus behavior, and ARIA props for both native button elements and custom element types.

Example
Button.tsx
Button.css
import {Button} from './Button';

<Button onPress={() => alert('Button pressed!')}>Press me</Button>

API

useButton(props: <ElementType>, ref: RefObject<any>): <HTMLAttributes<any>>

AriaButtonProps

NameTypeDefault
isDisabledbooleanDefault:

Whether the button is disabled.

childrenReactNodeDefault:

The content to display in the button.

targetstringDefault:

The target window for the link.

elementTypeElementTypeJSXElementConstructor<any>Default: 'button'

The HTML element or React element used to render the button, e.g. 'div', 'a', or RouterLink.

ButtonAria

NameType
buttonPropsT

Props for the button element.

isPressedboolean

Whether the button is currently pressed.