Content
Icon
A small picture next to words, to help people find and recognise things quickly.
GGDS has its own set of icons for government services, @ggds/icons. See all the icons, with what each one is for.
When to use
- To help people scan a list of services, links or actions and find the one they want.
- For a common action whose icon most people already know: download, print, search, menu.
- To show the type of a link: a file to download, a website outside government, a phone number.
When not to use
- On its own, without words. People guess the meaning of an icon differently, and many will not guess at all.
- To decorate a page or fill space. Every icon is one more thing to look at.
- For a status. Use a tag or a notice, which say it in words.
How to use
- Put the icon before the words, or after them for "next" and "continue" arrows. Wrap both in
ggds-with-iconso they line up. - Use the same icon for the same thing everywhere on your website, and only for that thing.
- Use the default size next to body text,
ggds-icon--smnext to small text, andggds-icon--xlabove a card's heading. - Do not change the stroke or colour of one icon: they are drawn to look like a set.
- If GGDS has no icon for what you need, use words alone and ask for one. Do not mix in icons from other sets.
Adding icons to your website
With npm
Import only the icons you use: your bundler leaves out the rest.
import { download, svg } from '@ggds/icons';
element.innerHTML = svg(download) + '<span>Download the form</span>';
Astro, the documentation and other templates that pick icons by name can use icon(name) from @ggds/icons/all. In Django use {% ggds_icon "download" %}; in the WordPress theme, ggds_icon( 'download' ).
Without npm
The GGDS download has every icon in ggds/icons/. Either copy the SVG of one icon from icons/svg/ into your page, with class="ggds-icon" aria-hidden="true" focusable="false", or point to the sprite, which the browser downloads once and keeps:
<svg class="ggds-icon" aria-hidden="true" focusable="false"><use href="/ggds/icons/sprite.svg#download"/></svg>
Do
- Write "Download the form" next to the download icon.
- Keep to a few icons on a page.
Don't
- Make a button that is only an icon, except search and menu in the header.
- Use an icon to mean two different things.
Accessibility
What GGDS does
- Icons take the colour of the text around them (
currentColor), so they keep its contrast in every theme and in Windows high contrast mode. svg(),icon(),{% ggds_icon %}andggds_icon()hide icons from screen readers (aria-hidden="true") and keep them out of the tab order (focusable="false"), because the words beside them already say it.- Every icon is drawn with a 2px line on a 24px grid, so it stays clear at small sizes and when zoomed.
What you need to do
- Put words next to every icon.
- If an icon really must stand alone, give it a name:
svg(download, { label: 'Download' }), orrole="img" aria-label="Download"on the<svg>. In a button or link, put the name on the button or link instead. - Keep an icon in a link or button inside its target, so the whole thing is at least 44px tall to press (WCAG 2.5.8).
Example: Icons beside words
<p><a href="#" class="ggds-with-icon"><svg class="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M12 4v11M7 10l5 5 5-5"/><path d="M4 20h16"/></svg><span>Download the application form (PDF, 120 KB)</span></a></p>
<p><a href="#" class="ggds-with-icon"><svg class="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M12 21s-6.5-5.8-6.5-11a6.5 6.5 0 0 1 13 0c0 5.2-6.5 11-6.5 11z"/><circle cx="12" cy="10" r="2.5"/></svg><span>Find your nearest office</span></a></p>
<p><span class="ggds-with-icon"><svg class="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/></svg><span>Open Monday to Friday, 8am to 5pm</span></span></p><>
<p><a href="#" className="ggds-with-icon"><svg className="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M12 4v11M7 10l5 5 5-5" /><path d="M4 20h16" /></svg><span>Download the application form (PDF, 120 KB)</span></a></p>
<p><a href="#" className="ggds-with-icon"><svg className="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M12 21s-6.5-5.8-6.5-11a6.5 6.5 0 0 1 13 0c0 5.2-6.5 11-6.5 11z" /><circle cx="12" cy="10" r="2.5" /></svg><span>Find your nearest office</span></a></p>
<p><span className="ggds-with-icon"><svg className="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="8.5" /><path d="M12 7.5V12l3 2" /></svg><span>Open Monday to Friday, 8am to 5pm</span></span></p>
</>Example: Icon sizes
<p>
<span class="ggds-with-icon"><svg class="ggds-icon ggds-icon--sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4M9 12h6M9 16h6"/></svg><span>Small</span></span>
<span class="ggds-with-icon"><svg class="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4M9 12h6M9 16h6"/></svg><span>Medium (the default)</span></span>
<span class="ggds-with-icon"><svg class="ggds-icon ggds-icon--lg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4M9 12h6M9 16h6"/></svg><span>Large</span></span>
<span class="ggds-with-icon"><svg class="ggds-icon ggds-icon--xl" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4M9 12h6M9 16h6"/></svg><span>Extra large</span></span>
</p><p>
<span className="ggds-with-icon"><svg className="ggds-icon ggds-icon--sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z" /><path d="M14 3v4h4M9 12h6M9 16h6" /></svg><span>Small</span></span>
<span className="ggds-with-icon"><svg className="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z" /><path d="M14 3v4h4M9 12h6M9 16h6" /></svg><span>Medium (the default)</span></span>
<span className="ggds-with-icon"><svg className="ggds-icon ggds-icon--lg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z" /><path d="M14 3v4h4M9 12h6M9 16h6" /></svg><span>Large</span></span>
<span className="ggds-with-icon"><svg className="ggds-icon ggds-icon--xl" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M6 3h8l4 4v14H6z" /><path d="M14 3v4h4M9 12h6M9 16h6" /></svg><span>Extra large</span></span>
</p>Example: An icon in a button
<div class="ggds-button-group">
<button class="ggds-button ggds-button--secondary ggds-with-icon" type="button"><svg class="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M7 9V4h10v5"/><rect x="4" y="9" width="16" height="7" rx="1"/><path d="M7 14h10v6H7z"/></svg><span>Print this page</span></button>
<button class="ggds-button ggds-with-icon" type="button"><span>Continue</span><svg class="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button>
</div><div className="ggds-button-group">
<button className="ggds-button ggds-button--secondary ggds-with-icon" type="button"><svg className="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M7 9V4h10v5" /><rect x="4" y="9" width="16" height="7" rx="1" /><path d="M7 14h10v6H7z" /></svg><span>Print this page</span></button>
<button className="ggds-button ggds-with-icon" type="button"><span>Continue</span><svg className="ggds-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d="M5 12h14M13 6l6 6-6 6" /></svg></button>
</div>Use it
- Stylesheet
ggds.cssincludes it. To load only the parts you use:core.css, thencomponents/icon.css(0.3 KB with gzip, minified).- JavaScript
- None needed.
HTML
Copy the HTML under each example above. It works in any website.
Astro
No Astro component: copy the HTML.
React and Next.js
With @ggds/react:
import { Icon } from '@ggds/react';
<Icon name="download" /> {/* hidden from screen readers: put words beside it */}Django
With ggds-django ({% load ggds %}):
{% ggds_icon "download" %}Classes and states
| Class | What it does |
|---|---|
.ggds-icon | A GGDS icon, 20px (the md icon size), in the colour of the text around it. |
.ggds-icon--sm | 16px, for small text. |
.ggds-icon--lg | 24px, the size the icons are drawn at. |
.ggds-icon--xl | 32px, for cards and lists of services. |
.ggds-with-icon | An icon and its words side by side, centred on each other, with a small gap. Works on links and buttons too. |
Accessibility tests
Automated, on every change
These run each time GGDS changes. A change that fails one is not accepted.
- WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
- No sideways scrolling on a 320px screen, also with a wide font, on every example
- Every approved colour pair meets its contrast minimum, for every institution theme
- No inline scripts or styles, so it runs under a strict Content Security Policy
By people, with assistive technology
Automated tests find only some of the barriers people meet. These checks are still to be done.
| Check | Result | Notes |
|---|---|---|
| Keyboard only | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| NVDA screen reader with Firefox or Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| JAWS screen reader with Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| VoiceOver screen reader with Safari (iPhone) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| TalkBack screen reader with Chrome (Android) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Zoom to 400%, and increased text spacing | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Windows contrast themes (forced colours) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Voice control (Voice Access or Dragon) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
Changes
| Version | Change |
|---|---|
| 0.3.0 | New: icon, ggds-icon with sizes ggds-icon--sm, --lg and --xl, and ggds-with-icon to put an icon and its words side by side. |
| 0.1.0 | Added. |
Related components
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.