Button
Open in Storybook Open in Figma
Buttons are used for interactive elements. You can find real-world examples in the Button examples.
Rules For Copywriters
- You find guides for wording of Buttons in the section UI text.
Label
Rules For Developers
- The
childrenare the label. They are mandatory, even when only the icon is displayed. - Consider making the accessible label (
aria-label) available for Copywriters, see Rules for Accessibility under UI text. - There is no accessible text for the icon itself, so the text provided via
childrenoraria-labelmust convey the meaning. - A button can take a
pill, which will be added after the label, but pill usage is currently restricted to buttons in PrimaryNavigation.
Variants
Inverted variants
Button variants invert to white when placed on coloured backgrounds:
Rules For Developers
- The variant automatically inverts when being placed in a
.g-invertedcontainer
Sizes
Rules For Designers
- Global styles
- Buttons only support a single line of text – it is ellipsed when too long
- Buttons are as wide as their content on tier
SMand up and are 100% onXS
- Small size styles
32pxheight (including border)14/16pxfont size8pxhorizontal padding (including border)
- Regular size styles
40pxheight (including border)16/24pxfont size24pxhorizontal padding (including border)
Rules For Developers
- Add
fullWidthprop to control whether the Button turns full-width below certain tiers
Disabled
Rules For Developers
- Every Button can be disabled by adding a
disabledattribute
Icon
Rules For Developers
- The
childrenare the label, and they are mandatory, independent of the Button’s visual appearance - Set the
hiddenLabelprop to control whether the label is shown
Using a link
Rules For Developers
- If it goes somewhere, use a link. If it does something, use a Button. In other words, links need a meaningful URL to go to, which may be a remote destination, but also somewhere else on the same page (i.e. an anchor). Make sure to get it right, as the two have their distinct behaviour – Buttons are triggered by pressing Space while anchor links by pressing Enter.
ButtonGroup
Use ButtonGroup to lay out a group of Buttons.
HINT Resize your browser to see what happens.
Rules For Designers
- Horizontal space between regular sized Buttons is 20px. Small Buttons have a 50% reduced horizontal spacing (10px).
- Vertical space between Buttons is 10px, but 20px to other elements (e.g. paragraphs and headlines).
Rules For Developers
- Always put Buttons in
.g-group.g-group-buttoncontainers - Make sure there is no whitespace between closing and opening braces of two Buttons
- If you need alignment, use Bootstrap’s
.text-left/.text-center/.text-righton the container - Don’t put other HTML elements in a
.g-group-buttoncontainer - they are designed to work with Buttons only. - For details on
.g-groupsee Typography.
ClearableButton
ClearableButton is used in the George searchbar and it includes another button to clear itself.
CircularButton
CircularButton is a component designed for creating circular icon-based buttons with optional labels. It wraps around the Button component while restricting and customizing its API to support specific styles, sizes, and icon usage.
Variants
Variants define the visual style of the button.
Sizes
Sizes control the overall dimensions of the button.