Sizes
| Size | Height | Label | Icon | Icon-only | Context |
|---|---|---|---|---|---|
xxs | 16px | 12px | 16px | 16 x 16 | Inside a chip or a tag |
xs | 24px | 14px | 16px | 24 x 24 | Compact rows and in-canvas chrome |
sm | 32px | 14px | 16px | 32 x 32 | Row actions, table toolbars, beside a sm field |
md | 40px | 14px | 16px | 40 x 40, 20px | The default. Forms, panel headers, beside md |
lg | 48px | 14px | 16px | 48 x 48, 20px | The most common standalone action, beside lg |
xl | 64px+ | 14px | 16px | 64 x 64, 24px | Bleeds to the edge of a modal or side panel |
xxl | 80px+ | 14px | 16px | 80 x 80, 32px | Full-screen surfaces: wizards and takeovers |
The label is 14px at every size from xs up, so a bigger button is a bigger target, not louder type. Icon-only buttons are square at every size, and their icon grows with them on the icon scale (16, 20, 24, 32).
Anatomy
| Part | Value |
|---|---|
| Start padding | 16px |
| End, with or no icon | 64px: 16px padding, the 16px icon, at least 32px of gap |
| Label to icon | 32px minimum. The label starts left, the icon is pinned right |
| Ghost and danger-ghost | 16px both sides, the icon 8px after the label |
| Radius | The control radius (--nb-radius-control) |
The two primary buttons above are the same width: the second has no icon, and keeps the space for one. That is what lets the spinner replace the icon while a button loads without the button changing size.
Centred, for a website
The anatomy above is for apps, where a button lines up with the fields, rows and panels around it. On a website a call to action stands on its own in a hero or a card, and the 64px kept for an icon reads as a label pushed off centre. align="center" centres the label with 16px on both sides, and an icon follows the label 8px later, as on a ghost.
A website sets it once for every button, and a button can still opt back out with align="start":
app.use(NubiscoUI, { button: { align: 'center' } })A width set by the layout (a full-width button on a phone, a button in a set) keeps the label in the middle. Link buttons are text in a line and keep their start alignment.
Wrapping at xl and xxl
Up to lg a button is one line tall. At xl and xxl the height is a minimum, the label sits at the top left, and a long label wraps onto a second line rather than overflowing. The icon stays pinned to the top right, centred on the first line. The width stops at 20rem, unless the button fills a set.
A label never truncates. At the one-line sizes, a label that does not fit is too long, or the layout is too tight: fix one of those rather than adding an ellipsis.
States
Every state of one button, side by side. Point at the first two, and Tab to them, to see hover and focus.
- Hover darkens a filled button one step (
-hover), fills an outlined one with its own colour, and lays the neutral surface hover under a ghost. - Focus is one ring for every control: 2px of
--nb-c-focus-ringdrawn inside the edge, with a 1px band of the surface inside that, so the ring stays legible on a filled button whose colour is close to it. - Disabled takes the disabled tokens, not a fade: a filled button the disabled fill, an outlined one the disabled border, a ghost or link only the disabled text. It no longer reads as a paler primary.
- Loading keeps the button's colours and its width. The spinner takes the icon's slot, and a button without an icon already reserves that slot.
- Pressed (
pressed) draws a selected fill on a ghost toggle while it is on.
Variants
The first five are the emphasis ladder, the three danger styles are ranked the same way, and the last three say what a press means rather than how loud it is.
Link
variant="link" is a button that reads as a text link: no fill, no box, an underline on hover and on keyboard focus. Use it for an action that sits inside text or a table cell, where a boxed button would be louder than the line around it: the key in a row that opens its record, "Select" beside a field, the way back out of a detail view.
It takes the font size, weight and line height of where it sits, so it lines up with the text beside it, and size does not change it. It is still a real <button>, <a> or <RouterLink> (from click, href or to, as every other variant), so Enter and Space work, disabled works, and it shows the focus ring.
<NbButton variant="link" @click="open(key)">{{ key }}</NbButton>
<NbButton variant="link" to="/settings/locales">Read about locales</NbButton>
<NbButton variant="link" disabled>Retry the import</NbButton>The colour is the primary drawn as ink, the same colour an outlined primary button uses, which clears WCAG AA on every layer in light and dark. Hover and focus add an underline and never a wash, so the colour it is read on does not change.
To take the colour of the surrounding text instead (a list where every row is a link, where a column of primary text would be noise), set --nb-button-link-color: currentColor on the button or an ancestor. Use currentColor, not inherit: on a custom property, inherit inherits the property, not the colour.
Outlined
tertiary and danger-tertiary are the two outlined buttons with a name, and the ones to reach for. outlined is the same treatment as a modifier, for the status variants: it removes the fill and draws the border and text instead. Ghost and link ignore it, since they have no fill to remove.
The text, border and focus ring of an outlined button are drawn straight onto the surface behind it, so they use the variant's ink rather than its fill colour. It is moved away from the surface (darker in light mode, lighter in dark) until it clears WCAG AA on every layer. Under the pointer an outlined button fills with its own colour, the way Carbon's tertiary does.
<NbButton variant="tertiary">Export</NbButton>
<NbButton variant="danger-tertiary">Delete</NbButton>
<NbButton variant="success" outlined>Mark as paid</NbButton>Styling
Every variant reads a semantic token, so a retheme moves the button with the rest of the product. Override the token, not the button. The full table is on the Code tab.
.nb-button--primary {
background: var(--nb-c-primary);
color: var(--nb-c-primary-a11y);
}