NbButton is the library's action control. Its job on any given screen is to make one action obvious and keep the rest available without competing.
Action hierarchy
Three variants carry the hierarchy. Reach for these first; the status colours below are a different tool for a different job.
<NbButton variant="ghost">Cancel</NbButton>
<NbButton variant="secondary">Save draft</NbButton>
<NbButton variant="primary">Publish</NbButton>| Variant | Use it for |
|---|---|
primary | The one action the screen exists for. At most one per view. |
secondary | A real alternative the user might reasonably take instead. |
ghost | Everything else: Cancel, Back, and toolbar actions. |
One primary per view. Two filled buttons side by side is two screens' worth of emphasis on one, and the eye picks neither.
Cancel is never danger. Cancel does not destroy anything; the button it sits next to might.
When a status colour is right
success, info, warning and danger say what a press means, not how loud it should be. Use one only when the semantics match:
<NbButton variant="ghost">Cancel</NbButton>
<NbButton variant="danger">Delete environment</NbButton>danger belongs on a control that destroys something. It is not a way to make a button louder, and a screen with three red buttons has told the user nothing. success on a Save button is the common mistake: saving is the primary action, not a positive outcome, so it takes primary.
For a destructive action, the dialog does the guarding: see NbConfirm and Dialogs.
Basic Usage
Icon Button
An icon-only button has no text for a screen reader to announce, so give it a name. aria-label is the usual way. v-nb-tooltip also works, because it writes the tooltip text to aria-label when the button has no other name.
<NbButton icon="trash" aria-label="Delete" />
<NbButton v-nb-tooltip="{ body: 'Delete' }" icon="trash" />In development, an icon-only button that renders without aria-label, aria-labelledby, title or text logs a warning naming the icon, once per icon. Production builds stay silent.
Features
- Color Tints: Six distinct color variants (primary, secondary, success, info, warning, danger)
- CSS Custom Properties: Uses design system variables for theming
Examples
Form Integration
Realistic groups
Every group above has exactly one filled button, and the exit is always ghost. See the whole pattern working on a real screen in Team management.