- Taxonomic name: A-BUTTON
- Added on: v3.0.0 (15/09/17)
- Updated on: v2023.01 (27/10/23)
Buttons
Buttons are used to initiate an action or for navigation.
Design and usage
- Keep labels simple and short – no more than two or three words long and clearly describing the action or destination.
- Additional invisible text can be included to ensure the accessibility of the link.
- All buttons other than the transparent button are built to work on light and dark accent colours.
- All buttons have a minimum height of 55px and a minimum width of 100px to ensure a sensible clickable / tappable size.
- Primary buttons should be the most visually prominent element on the page.
- Transparent buttons are for use as an alternative for primary buttons on dark accent colours.
- Icon buttons can be used to highlight certain actions such as download etc.
- Print buttons should only be used when linking to a page that is specifically designed for printing, or if being added via JavaScript to print the current page.
- Full width buttons should be used where a button must display the full width of its container.
- Next and back buttons should be centralised where space allows.
- Buttons display at full width in mobile views.
- See style guide for colour and typography rules.
- Icons should not be used on transparent buttons on accent colours.
- Avoid using multiple instances of primary buttons on the same page; instead use secondary button styles, links, chevrons or imagery to differentiate calls to action.
- Anchors must not open in a new window, eg.
target="_blank"
, unless it would disrupt a users journey such as when within a large form. Read more about opening links in new windows.
Examples
Primary
The primary button should be the most visually prominent element on the page. If possible, avoid using multiple instances of primary buttons on the same page; instead use secondary button styles, links, chevrons or imagery to differentiate calls to action.
Interactive example
Code example
<button class="a-button a-button--primary">...</button>
<!-- or --->
<a class="a-button a-button--primary" href="...">...</a>
Primary buttons with icons
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--primary a-button--[ icon ]">...</button>
<!-- or --->
<a class="a-button a-button--primary a-button--[ icon ]" href="...">...</a>
Primary buttons with icons inversed
Les boutons avec des icônes '--next', '--previous', '--back' et '--filter' ne seront pas inversés
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--primary a-button--[ icon ] a-button--inverse-icon">...</button>
<!-- or --->
<a class="a-button a-button--primary a-button--[ icon ] a-button--inverse-icon" href="...">...</a>
Secondary
Interactive example
Code example
<button class="a-button a-button--secondary">...</button>
<!-- or --->
<a class="a-button a-button--secondary" href="...">...</a>
Secondary buttons with icons
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--[ icon ]">...</button>
<!-- or --->
<a class="a-button a-button--[ icon ]" href="...">...</a>
Secondary buttons with icons inversed
Les boutons avec des icônes '--next', '--previous', '--back' et '--filter' ne seront pas inversés
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--[ icon ] a-button--inverse-icon">...</button>
<!-- or --->
<a class="a-button a-button--[ icon ] a-button--inverse-icon" href="...">...</a>
Tertiary
Tertiary buttons are designed to look like a standard text link but provide a larger than standard hit target.
Interactive example
Code example
<button class="a-button a-button--tertiary"><span class="a-button__inner">...</span></button>
<!-- or --->
<a class="a-button a-button--tertiary" href="..."><span class="a-button__inner">...</span></a>
With icons
<button class="a-button a-button--tertiary a-button--[ Modifier ]"><span class="a-button__inner">...</span></button>
<!-- or --->
<a class="a-button a-button--tertiary a-button--[ Modifier ]" href="..."><span class="a-button__inner">...</span></a>
Tertiary shallow
This variant should be used with lists of links to avoid excessive white space and physical length of each list.
Interactive example
Code example
<button class="a-button a-button--tertiary a-button--tertiary-shallow a-button--[ Modifier ]"><span class="a-button__inner">...</span></button>
<!-- or --->
<a class="a-button a-button--tertiary a-button--tertiary-shallow a-button--[ Modifier ]" href="..."><span class="a-button__inner">...</span></a>
Tertiary shallow button list
This variant should be used with lists of links to avoid excessive white space and physical length of each list. See lists for more detail.
Interactive example
Code example
<ul class="a-list-plain a-list-plain--tertiary-buttons">
<li><button class="a-button a-button--tertiary a-button--tertiary-shallow [ Modifier ]"><span class="a-button__inner">...</span></button></li>
<li><a class="a-button a-button--tertiary a-button--tertiary-shallow [ Modifier ]" href="..."><span class="a-button__inner">...</span></a></li>
</ul>
Transparent
Transparent buttons are for use as an alternative for primary buttons on dark accent colours. These can not be used with icons.
Interactive example
Code example
<button class="a-button a-button--transparent">...</button>
<!-- or --->
<a class="a-button a-button--transparent" href="...">...</a>
Form
ONLY to be used when placing a primary or secondary button next to a form element. The reduced height of these buttons means they align with form elements perfectly unlike other button variants.
Interactive example
Code example
<button class="a-button [ Modifier ] a-button--form">...</button>
<!-- or --->
<a class="a-button [ Modifier ] a-button--form href="...">...</a>
Only to be used when linking to a page that is specifically designed for printing, or if being added via javascript to print the current page. Icon buttons should NOT be used on transparent buttons on accent colours.
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--primary a-button--print">...</button>
<!-- or --->
<a class="a-button a-button--primary a-button--print" href="...">...</a>
Watch video
Icon buttons should NOT be used on transparent buttons on accent colours.
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--primary a-button--video">...</button>
<!-- or --->
<a class="a-button a-button--primary a-button--video" href="...">...</a>
Live-chat
Icon buttons should NOT be used on transparent buttons on accent colours.
Interactive example
Code example
Note: icon buttons will NOT work correctly with
<input>
elements as they are not
compatible with the CSS :after
pseudo
element. Please use either the button or anchor element.
<button class="a-button a-button--livechat">...</button>
<!-- or --->
<a class="a-button a-button--livechat" href="...">...</a>
Disabled
Interactive example
Code example
Note: Form elements can be disabled by simply setting
the disabled
attribute (although the class
of is-disabled
will still work). Anchor
buttons are unable to use this attribute, so can only make use of the
class, however the aria-disabled="true"
attribute should also be added to ensure that the inactive state of the
button is announced to screen readers.
Caveat: Events are attempted to be suppressed by setting
pointer-events: none
, however this is only
supported in modern
browsers, and as such it is recommended to use javascript to
disable on legacy browsers.
<button class="a-button" disabled>...</button>
<!-- or --->
<a class="a-button is-disabled" href="..." aria-disabled="true">...</a>
Full width button
Make a button display full width of its container.
Interactive example
Code example
<a class="a-button a-button--full-width" href="...">...</a>
Button group
Group of buttons on one line.
Interactive example
Code example
<ul class="m-button-group">
<li class="m-button-group__item">...</li>
<li class="m-button-group__item">...</li>
</ul>
Button group of three (first button feature)
Group of buttons three on one line, with the first button being a featured primary button; at small screen sizes, the two secondary buttons stay side-by-side under the primary button.
Interactive example
Code example
<ul class="m-button-group m-button-group--feature-three">
<li class="m-button-group__item">...</li>
<li class="m-button-group__item">...</li>
</ul>
Next and previous button group
Next and back buttons which are centralised on screen when on large enough screens.
Interactive example
Code example
<ul class="m-button-group m-button-group--pagination">
<li class="m-button-group__item"><!-- Next button --></li>
<li class="m-button-group__item m-button-group__item--previous"><!-- Previous button --></li>
</ul>
Sticky button
Make a button sticky at the bottom of the screen on mobile only.
Interactive example
Code example
<button class="a-button a-button--primary a-button--sticky" data-module="a-button-sticky">...</button>
<!-- or --->
<a class="a-button a-button--primary a-button--sticky" href="..." data-module="a-button-sticky">...</a>
Sticky button double
Make two buttons sticky at the bottom (left and right) of the screen on mobile only.
Interactive example
Code example
<button class="a-button a-button--[ Modifier ] a-button--sticky a-button--sticky-left" data-module="a-button-sticky">...</button>
<!-- or --->
<a class="a-button a-button--[ Modifier ] a-button--sticky a-button--sticky-left" href="..." data-module="a-button-sticky">...</a>
<!-- and --->
<button class="a-button a-button--[ Modifier ] a-button--sticky a-button--sticky-right" data-module="a-button-sticky">...</button>
<!-- or --->
<a class="a-button a-button--[ Modifier ] a-button--sticky a-button--sticky-right" href="..." data-module="a-button-sticky">...</a>
Development and test
Notes for developers
Using disabled buttons
Do not rely solely on the is-disabled
class to
disable buttons (<button>
), but rather
explicitly provide the disabled
attribute.
<button class="a-button is-disabled" type="submit" disabled>...</button>
The disabled
attribute is not valid for anchor
tags, so when using these as buttons, add the is-disabled
class in conjunction with the aria-disabled="true"
attribute to ensure that
the inactive state of the button is clear visibly and also announced as such to
screen readers.
<a class="a-button is-disabled" href="..." aria-disabled="true">...</a>
Visible labels and accessible names
When a button needs to be more descriptive of what it is or where it is going,
but there is a requirement to show simplified text, then an extra span with the
class u-hidden--visually
is required within the
a-button
to hold the hidden text required to make
the accessible name for the label meaningful to screen readers. The visible
label should always come first, with the hidden text following on to extend this
by adding meaning and context, for example:
<button class="a-button" href="...">Find out more<span class="u-hidden--visually"> about car insurance</span></button>
This also helps to ensure that all buttons and links are unique through the page, rather than having multiple instances of links simply saying "Read more".
Links to external websites
If a link is taking the user to an external website, ensure that it is clear that it will do so by making the title attribute descriptive of what it will do and where it will go, for example:
<a href="https://www.google.com" title="External site - www.google.com" rel="external">Google</a>
Accessibility testing
All Framework components have been accessibility tested, including being scanned using AXE. This component will cause rule violations using the standard AXE configuration (as would be seen if using their browser plugin), some of which may well be false positives; see our accessibility page for details on what rules have been excluded for this component and why.
Notes for testers
- Ensure that buttons can be accessed via the mouse as well as via tabbing using the keyboard.
- Use a screen reader to confirm that the buttons are understandable as to where they will be going when listed out of context of the page.
- Ensure that when hovering over a button, the style changes noticeably.
- Ensure that when a button has focus, the style changes noticeably.
- Ensure that text within buttons is descriptive of what or where the button is going. Additional text descriptive text can be hidden visually from the user to aid to help make the button understandable, especially if there area number of links / buttons such as "Find out more" on the page which go to different locations.
- Ensure that all buttons are device agnostic and do not specify how a user should be interacting with a button, eg. click.
Classes overview
The following table gives you a quick overview of the CSS classes that can be applied.
Class | Outcome | Required | Applied to | Comments |
---|---|---|---|---|
.a-button |
Base button style (white), hover/focus blue | Yes | button , input , a |
|
.a-button--primary |
Primary button (yellow), hover/focus blue | .a-button |
||
.a-button--tertiary |
Tertiary button styling to resemble text link | .a-button |
||
.a-button--tertiary-shallow
|
Tertiary button variant to reduce the vertical height of the button to 44px | .a-button--tertiary |
||
.a-button--transparent |
Transparent button, hover/focus blue | .a-button |
||
.a-button--form |
Form button | .a-button |
To be used on primary and secondary buttons in conjunction with form elements. | |
.a-button--accessibility |
Accessibility button with icon | .a-button |
||
.a-button--add |
Add button with icon | .a-button |
||
.a-button--attachment |
Attachment button with icon | .a-button |
||
.a-button--auto-renewal |
Auto-renewal button with icon | .a-button |
||
.a-button--back |
Reply/back button with icon | .a-button |
||
.a-button--bookmark |
Bookmark button with icon | .a-button |
||
.a-button--calculator |
Calculator button with icon | .a-button |
||
.a-button--call |
Call button with icon | .a-button |
||
.a-button--claim |
Claim button with icon | .a-button |
||
.a-button--delete |
Delete button with icon | .a-button |
||
.a-button--document |
Document button with icon | .a-button |
||
.a-button--download |
Download button with icon | .a-button |
||
.a-button--edit |
Edit button with icon | .a-button |
||
.a-button--external |
External link button with icon | .a-button |
||
.a-button--filters |
Filters button with icon | .a-button |
||
.a-button--geo-location |
Geo-location button with icon | .a-button |
||
.a-button--information |
Information button with icon | .a-button |
||
.a-button--links |
Links button with icon | .a-button |
||
.a-button--livechat |
Live-chat button with icon | .a-button |
Only available as a blue or tertiary button |
|
.a-button--location |
Location button with icon | .a-button |
||
.a-button--medical-professional |
Medical-professional button with icon | .a-button |
||
.a-button--message |
Message button with icon | .a-button |
||
.a-button--messenger |
Messenger button with icon | .a-button |
||
.a-button--new-window |
New-window button with icon | .a-button |
||
.a-button--next |
Next button with icon | .a-button |
||
.a-button--opening-hours |
Opening-hours button with icon | .a-button |
||
.a-button--places |
Places button with icon | .a-button |
||
.a-button--previous |
Previous button with icon | .a-button |
||
.a-button--print |
Print button with icon | .a-button |
||
.a-button--profile |
Profile button with icon | .a-button |
||
.a-button--remove |
Remove button with icon | .a-button |
||
.a-button--rss |
RSS button with icon | .a-button |
||
.a-button--save |
Save button with icon | .a-button |
||
.a-button--search |
Search button with icon | .a-button |
||
.a-button--secure |
Secure button with icon | .a-button |
||
.a-button--share |
Share button with icon | .a-button |
||
.a-button--upload |
Upload button with icon | .a-button |
||
.a-button--view-list |
View as list button with icon | .a-button |
||
.a-button--view-grid |
View as grid button with icon | .a-button |
||
.a-button--top |
Top button with icon | .a-button |
||
.a-button--inverse-icon |
Inverse the default position (left/right) of the icon | .a-button.a-button--[icon] |
||
.is-disabled |
Disabled button with no states (greyed out) | .a-button |
||
.a-button__inner |
Styling for adding underline on tertiary buttons | Yes | .a-button--tertiary > span |
|
.a-button--full-width |
Make button stay full width of its container | .a-button |
||
.m-button-group |
Grouping of buttons left to right | Yes | ul |
|
.m-button-group--feature-three
|
Modifier for button group - places second two buttons on same line at small screens | .m-button-group |
Only to be used with three buttons, with the first being a primary button | |
.m-button-group--pagination
|
For placing next and previous buttons centrally. Next button appears before Previous button a small screen but to the right on medium or large screen | .m-button-group |
||
.m-button-group__item |
Grouping of buttons left to right | Yes | .m-button-group > li |
|
.m-button-group__item--previous |
Modifier for use with the pagination button group to adjust the alignement of the previous button | .m-button-group--pagination
.m-button-group__item |
||
.a-button--sticky |
Make a button sticky at the bottom of the screen on mobile only | .a-button |
To be used on primary and secondary buttons. Tertiary buttons are NOT supported. | |
.a-button--sticky-left |
Make a button sticky at the bottom-left of the screen on mobile only | .a-button--sticky |
To be used on primary and secondary buttons in conjunction with bottom-right sticky button. Tertiary buttons are NOT supported. | |
.a-button--sticky-right |
Make a button sticky at the bottom-right of the screen on mobile only | .a-button--sticky |
To be used on primary and secondary buttons in conjunction with bottom-left sticky button. Tertiary buttons are NOT supported. |
Keyboard operations
- TAB
-
Tabbing to an anchor should make the button clearly visually different so that the focus point on the page is obvious to the user.
- SPACE or ENTER
-
With focus on a button, pressing SPACE or ENTER will open the link if a link or perform the form action. If the link is internal to the page it will scroll the page otherwise it will load the new page.
Component releases
- Added on: v3.0.0 (15/09/17)
- Updated on: v2023.01 (22/05/23)
Latest update:
- added : Class '.a-button--inverse-icon' to inverse left/right the default position of the icon
- updated: Sticky button modifier has been added.