Button primitive
Headless Button: the behavior, keyboard support and ARIA of the WAI-ARIA Button pattern, with no styles.
@ndop/primitives/button- WAI-ARIA: Button
Import
Primitives ship in the @ndop/primitives package and have no styles. Their state is on data attributes for you to style. The styled Button is built on this one.
import { NdButton } from '@ndop/primitives/button';Accessibility
Implements the Button pattern of the WAI-ARIA Authoring Practices.
Keyboard
Keys the component handles.
| Key | Action |
|---|---|
| Enter | Activates the button, or follows the link; does nothing while disabled. |
| Space | Activates a button; does nothing while disabled. Links don't react to Space. |
Focus
- A disabled
buttonand a disabledaare removed from the tab order. - Activation does not move focus.
Right-to-left
Nothing mirrors.
API reference
NdButton
button[ndButton], a[ndButton]role native (button / link)from @ndop/primitives/buttonHeadless button for a native button or an a styled as a button.
- On button: disabled sets the native attribute, and a missing static
type becomes type="button" so it never submits a form by accident.
- On a: anchors can't be natively disabled, so disabled sets
aria-disabled="true", removes it from the tab order and cancels
clicks before any other listener sees them.
- data-disabled is present while disabled, on both.
Manages aria-disabled.
| NdButton binding | Type | Default |
|---|---|---|
[disabled]Whether the button or link is disabled. | boolean | false |
| Data attribute | Values |
|---|---|
data-disabled | — |