Buttons
On this page
Buttons start an action: saving, adding, exporting, deleting. Every page has at most one primary button in view; everything else is a secondary, ghost or danger button.
Variants


Figure 1: Primary, secondary, ghost, danger, busy and disabled buttons
<button type="button" class="ph-btn ph-btn--primary">Save changes</button>
<button type="button" class="ph-btn">Cancel</button>
<button type="button" class="ph-btn ph-btn--ghost">Reset</button>
<button type="button" class="ph-btn ph-btn--danger">Delete</button>
<button type="button" class="ph-btn ph-btn--primary" aria-busy="true">Saving</button>
<button type="button" class="ph-btn" disabled>Disabled</button>
| Class | Looks like | Use for |
|---|---|---|
.ph-btn | Outlined, on the surface colour | Secondary actions: Cancel, Export, View all |
.ph-btn--primary | Blue fill | The page's or dialog's main action. One per view. |
.ph-btn--ghost | Blue text, no border | Low-emphasis actions: Reset, Back, Restart |
.ph-btn--danger | Red fill | Actions that destroy something. Confirm them first. |
States
| State | How | What happens |
|---|---|---|
| Busy | aria-busy="true" | The label is replaced by a spinner and the button can't be clicked. Set it while saving. |
| Disabled | disabled (or aria-disabled="true") | Faded and not clickable. |
| Focused | Keyboard focus | A blue focus ring. |
Sizes


Figure 2: Small, default and large buttons, and a full-width button
| Class | Height | Use for |
|---|---|---|
.ph-btn--sm | 26px | Card headers, callouts, toolbars and table rows |
| (default) | 30px | Everywhere else |
.ph-btn--lg | 36px | A single call to action on an otherwise empty page |
.ph-btn--block | Full width | Phone layouts and narrow panels |
Icons, icon buttons and groups


Figure 3: Buttons with icons, an icon button, an outlined icon button and a button group
<button type="button" class="ph-btn ph-btn--primary">
<svg class="ph-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14" /><path d="M12 5v14" /></svg>
Add contact
</button>
<button type="button" class="ph-icon-btn" aria-label="Refresh">...svg...</button>
<button type="button" class="ph-icon-btn ph-icon-btn--outlined" aria-label="More actions">...svg...</button>
<div class="ph-btn-group" role="group" aria-label="Period">
<button type="button" class="ph-btn ph-btn--sm">Day</button>
<button type="button" class="ph-btn ph-btn--sm">Week</button>
<button type="button" class="ph-btn ph-btn--sm">Month</button>
</div>
| Class | What it is |
|---|---|
.ph-icon-btn | A 30 × 30px button with only an icon, no border |
.ph-icon-btn--outlined | The same with an outline, to sit next to .ph-btns |
.ph-btn-group | Joins buttons into one control |
Put the icon before the label. For choosing one option from a few (Day, Week, Month), the segmented control shows which one is selected.
Accessibility
- Use a real
<button>(or<a>for navigation), never a clickable<div>. - Icon-only buttons need an
aria-labelthat says what they do, and their icon needsaria-hidden="true". Add a tooltip with the same words. - Buttons inside forms that don't submit need
type="button".
React
StyledButton from ph-app-kit-react is the same button as an MUI Button:
import { StyledButton } from 'ph-app-kit-react';
<StyledButton variant="contained" onClick={save}>Save changes</StyledButton>
<StyledButton variant="outlined">Cancel</StyledButton>
Guidelines
- Labels are verbs that say what happens: "Save changes", "Export CSV", "Delete project". Not "OK", "Submit" or "Yes".
- Use sentence case: "Add contact", not "Add Contact".
- Put the primary button last (rightmost) in headers, dialogs and forms.
- Confirm destructive actions with
phApp.dialog.confirm(), saying what will be lost. - Don't bind Ctrl/Cmd+K, Ctrl/Cmd+J, Ctrl/Cmd+I or Alt+Ctrl/Cmd+L to buttons: those shortcuts belong to Performance Hub.
Related
- Menus: more actions behind one button
- Dialogs and drawers
- Icons