What the component guarantees
- The right element for the job. With no
hrefortoit renders a native<button>withtype="button"by default, so it is focusable and activates on Enter and Space without any script of ours. Withhrefit renders an<a>, and with anyto(a string or a location object) and vue-router installed aRouterLink, so a button that navigates keeps middle-click, Cmd-click and "copy link address". Without a router, a stringtois a plain<a>. - Disabled means disabled. On a
<button>,disabled(andloading) set the nativedisabledattribute: the control leaves the tab order and is announced as unavailable. A link cannot be disabled natively, so a disabled or loading link renders a plain<a>with nohrefandaria-disabled="true": there is nothing left for Enter to follow, and the click is swallowed. - Icon-only buttons are named, and the name is the tooltip.
labelbecomes the accessible name and the tooltip anchored to the button, so the words a screen reader hears and the words a mouse user sees are the same words. The tooltip itself is hidden from assistive tech, so the name is not read twice. In development, an icon-only button with no name logs one warning per icon naming it. - Toggles say their state.
pressedsetsaria-pressed, so a toggle is announced as "toggle button, pressed" rather than by its colour alone. - One focus ring for every control. 2px of
--nb-c-focus-ringdrawn inside the edge, with a 1px band of the surface inside that. The inner band keeps the ring legible on a filled button whose colour is close to the ring's, and the outer band is anoutline, so it survives forced-colours mode. - Disabled is drawn from tokens, not opacity, so its contrast does not depend on what sits behind it.
- Decoration stays out of the name. The loading spinner is
aria-hidden="true", and icons are inline SVG that inheritcurrentColor, so they survive forced-colours mode. - A touch target on phones. On a phone touch screen the
hit-areamixin grows the tap box to 44px around the sizes below it (xxstomd) without changing how the button looks. A desktop is unchanged. - Checked by axe in
tests/axe.test.tson every run.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves to the button (skipped while disabled) |
| Enter | Activates a button or a link |
| Space | Activates a button (not a link, by design) |
What you own
- The
labelof an icon-only button. We cannot know what the icon means in your product. Name the action and, in a row, the row: "Edit invoice 2026/014". Do not addv-nb-tooltiporaria-labelas well. - Words that say what happens. "Save invoice" rather than "OK". A screen reader user often lists the buttons on a page out of context.
- Why a disabled row action is disabled. A disabled button cannot be focused, so its reason has to be visible where the row is: the tooltip of the row-action standard, or a line of text.
- Announcing the result of a long action.
loadingchanges how the button looks. It does not tell a reader that the save finished or failed. UseuseInlineLoadingor a toast. - A reason for a disabled button. Without one,
disabledis native: the button leaves the tab order and its tooltip never opens. Withdisabled-reasonit carriesaria-disabledinstead, stays reachable, swallows the press (a submit button does not submit), and the reason is its tooltip and its accessible description. type="submit"on the one button that submits a form. The default isbutton, so a button inside a<form>does not submit it by accident.
Known gaps
loadingdrops focus. On a<button>,loadingsets nativedisabled, and a browser moves focus off a control that becomes disabled, to<body>. A keyboard user who pressed Save starts again from the top of the page. Until that changes, move focus yourself when the action completes, or keep the button enabled and ignore repeat presses in your handler.