London City Data

Actions and emphasis

Choosing and pairing buttons

A button starts an action or goes to another page. Its variant sets how much weight it has, and its emphasis shows what the action does.

Give each view one main action, and make the actions around it lighter.

Variants

The variant sets the weight of a button, from the most to the least:

VariantLooks likeUse it for
solidA filled buttonThe main action in a view
outlineA border in the emphasis colour, with no fillA supporting action beside a solid button
textUnderlined text, with no fill or borderThe action with the least weight, or an action in a line of text
squareA filled square that shows an iconAn action that an icon can show on its own, such as opening a menu
brandA button with a bar in the GLA brand colourSparingly, never for every action in a view
<Button variant="solid">Solid</Button>
<Button variant="outline">Outline</Button>
<Button variant="text">Text</Button>
<Button variant="square" aria-label="Open menu"><Icon src={Bars3} class="h-5 w-5" /></Button>
<Button variant="brand">Brand</Button>

Emphasis

The emphasis shows what the action does. primary is for the main action and secondary for supporting actions. positive, negative and caution show the outcome of an action, such as publishing, deleting or archiving.

<Button emphasis="primary">Primary</Button>
<Button emphasis="secondary">Secondary</Button>
<Button emphasis="positive">Publish</Button>
<Button emphasis="negative">Delete</Button>
<Button emphasis="caution">Archive</Button>

Only the main action takes positive, negative or caution. The button beside it keeps a neutral emphasis.

Pairing buttons

Use one solid primary button in a view. Give a supporting action secondary emphasis or the outline variant, and use a text button for the action with the least weight.

The main action goes on the right, at the end of the reading order. Cancel and Back stay low in emphasis:

<Button variant="outline" emphasis="secondary">Cancel</Button>
<Button>Save changes</Button>
 
<Button variant="text">Back</Button>
<Button>Continue</Button>
 
<Button variant="outline" emphasis="secondary">Cancel</Button>
<Button emphasis="negative">Delete</Button>

Two primary buttons side by side compete for attention, so demote one to secondary. Two different status emphases side by side, such as Delete and Publish, conflict.

Two examples crossed out: a pair of primary buttons, Delete and Publish, and a negative Delete button beside a positive Publish button

In a modal, the buttons sit in the footer, aligned right with 8px between them. Feedback and overlays describes modals.

A button that goes to another page must be a link, because a screen reader announces a button and a link differently. Give Button an href and it renders an <a> styled as a button:

<Button href="/design-system/getting-started">Get started</Button>

For a link that needs a sentence of description, such as a link to a report, use PlacardButton.

Icon buttons

A square button shows an icon on its own. The sizes are 24, 32, 40 and 64px square.

  • Give a square button with no visible label an aria-label that names the action.
  • Show a label as well when the icon alone may not be understood.
  • Don't put a long label in a square button. Its width is fixed, so the label wraps.

Buttons for particular actions

Some actions have a component of their own:

ActionComponent
An action that takes time, such as savingAsyncButton, which shows a spinner while it runs
Copying textCopyButton
Downloading a chart's data or imageDownloadButton
One action in several versions, such as a download in different formatsMultipleActionButton

MultipleActionButton has a chevron that opens a menu of versions of its action. Each option must be a version of the same action, because the button runs the one chosen.

Building your own buttons

Use Button and the components above. Their colours, focus ring and label size come from the system.

In Storybook

Storybook has the props and states of Button and the other buttons.