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

Button variantsButton 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>
ClassLooks likeUse for
.ph-btnOutlined, on the surface colourSecondary actions: Cancel, Export, View all
.ph-btn--primaryBlue fillThe page's or dialog's main action. One per view.
.ph-btn--ghostBlue text, no borderLow-emphasis actions: Reset, Back, Restart
.ph-btn--dangerRed fillActions that destroy something. Confirm them first.

States

StateHowWhat happens
Busyaria-busy="true"The label is replaced by a spinner and the button can't be clicked. Set it while saving.
Disableddisabled (or aria-disabled="true")Faded and not clickable.
FocusedKeyboard focusA blue focus ring.

Sizes

Button sizesButton sizes

Figure 2: Small, default and large buttons, and a full-width button

ClassHeightUse for
.ph-btn--sm26pxCard headers, callouts, toolbars and table rows
(default)30pxEverywhere else
.ph-btn--lg36pxA single call to action on an otherwise empty page
.ph-btn--blockFull widthPhone layouts and narrow panels

Icons, icon buttons and groups

Buttons with icons, icon buttons and a button groupButtons with icons, icon buttons and a button group

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>
ClassWhat it is
.ph-icon-btnA 30 × 30px button with only an icon, no border
.ph-icon-btn--outlinedThe same with an outline, to sit next to .ph-btns
.ph-btn-groupJoins 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-label that says what they do, and their icon needs aria-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.