Button
Buttons let people do something: start a service, send a form or save their progress.
Updated
Live example
Button
Usage
<button class="nds-button nds-button--primary nds-button--md"> Start your application <svg class="nds-button__icon" aria-hidden="true">...</svg></button> Add the Button block, or paste this markup into the Code editor
<!-- wp:nds/button {"type":"primary","size":"md","icon":true} --><a href="/apply" class="nds-button nds-button--primary nds-button--md"> Start your application <svg class="nds-button__icon" aria-hidden="true" focusable="false" width="16" height="16"> <use href="#nds-icon-arrow-right"></use> </svg></a><!-- /wp:nds/button --> Usage
// Import the componentimport { Button, ArrowRight } from "@nigerian-design-standards/react";// Use it<Button variant="primary" size="md" icon={<ArrowRight />}> Start your application</Button> Usage
// Import the componentuse NDS\Components\Button;// Use itecho Button::render([ 'variant' => 'primary', 'size' => 'md', 'label' => 'Start your application', 'icon' => 'arrow-right',]); Overview
A button lets people do something: start a service, send a form or save their progress.
It’s the most common way people move forward on a government website.
Use a button to
- Start or submit something
- Save, confirm or continue
- Open a dialog on the same page
Don’t use a button to
- Go to another page (use a link)
- Show more text (use an accordion)
- Decorate a heading
Variants
Use one primary button per page. Everything else steps down from it.
Specifications
The properties developers set on the button: what each one is, its type and the values it accepts. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| type | string |
| How important the action is. Use one primary button per page. |
| size | string |
| Height and padding of the button. |
| icon | string |
| Shows an icon after the label. For an icon on its own, use type icon-only. |
| iconName | string |
| Which icon to show. Used when icon isn’t none. |
| label | string |
| The button text. Required. For icon-only buttons it becomes the accessible name. |
| disabled | boolean |
| Turns the button off. Prefer an enabled button and an error message on submit, so people can see what to fix. |
Hover, focus and pressed are states the browser handles, not properties you set.
Use cases
Do
One primary action, placed last, with a supporting action before it.
Don’t
Two primary buttons side by side. People won’t know which one matters.
Pairing and placement
How buttons sit together. The same order and spacing on every site make services quicker to use.
- Order
On desktop, right-align the buttons with the main action last: tertiary, secondary, then primary. On mobile, stack them full width with the primary on top.
- Spacing
12px between buttons, in a row or a stack.
- One primary
Only one primary in a group. If two actions matter equally, use secondary and tertiary.
- Dialogs
Use secondary and tertiary buttons only.
- ReportGov
Never next to a submit button, so people can’t file a complaint by mistake.
Copywriting
The label is the instruction. People should know what happens before they press.
- Start with a verb
“Start your application”, “Save and come back later”. Not “Application” or “OK”.
- Say what happens
“Send application” is clearer than “Submit” or “Continue” on its own.
- Keep it short
A few words. The button grows with the label, so long lines wrap on small screens.
- Icon-only
Only hide the label when the icon is unmistakable, and always add an accessible name.
Accessibility
Built on a native <button> element, so it works with keyboards, screen readers and browser defaults like submit on Enter in a form.
| Key | What it does |
|---|---|
| Enter | Activates the button. |
| Space | Activates the button when it has focus. |
| Tab | Moves focus to the next control. |
- Use a button for actions on the page and a link for going somewhere else, even when they look the same.
- Button text passes WCAG 2.2 AA contrast: 5.8:1 on primary, 14.3:1 on secondary and 16.3:1 on tertiary.
- Keyboard focus shows a visible ring. border/focus is 4.5:1 on the page.
- The smallest button is 32px high, above the 24px minimum target size (WCAG 2.5.8).
For developers
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
For designers
Use the nds-button component from 01 Library – Foundations. Don’t detach it.
References
Feedback
Is this page useful?