Tag
A word or two in a small rounded label: what something is about, or who it suits. It describes; it doesn't do anything.
Good for Families Diving First charters
Good for Families Diving First charters
Show code
<p>Good for <span class="sn-tag">Families</span> <span class="sn-tag">Diving</span></p>
<!-- Tags that go somewhere: a list of links -->
<ul class="sn-tags">
<li><a class="sn-tag" href="/yacht-charter/family/">Family charters</a></li>
<li><a class="sn-tag" href="/yacht-charter/diving/">Diving charters</a></li>
</ul> When to use it
- Yes: a short description that helps someone scan: a topic, a type, who something is good for.
- No: anything that can be pressed to change the page. A choice that filters a list is a filter button with a pressed state; a choice of view is a segmented control.
- Three or four beside one thing is plenty. More than that and none of them is read.
Tags as links
A tag may link to everything else with that tag. Then it is a link like any other: its words say where it goes ("Family charters", not "Family"), it sits in a list (ul.sn-tags, which sets the gaps and wraps), and pointing at it turns its edge the accent colour.
Tag, badge or status?
| Part | Class | What it's for |
|---|---|---|
| Tag | .sn-tag | Describes the thing beside it. Quiet, in running text or a list. |
| Badge | .sn-badge | A mark on a picture that sets one item apart: "Special offer". Solid accent, one per picture. |
| Status indicator | .status | A state that changes: a dot and words. |
| Result label | .sr-type | The kind of page on a search result. The same colours as a tag. |
Tokens
Fill, edge and words come from color.tag.bg, color.tag.border and color.tag.ink, set for light and dark, so a brand changes every tag at once. The corners are a full pill and the type is 14px.
Do and don't
Do
- One to three words
- The same word for the same thing everywhere
Don't
- Use a tag as a button or a filter
- Colour-code tags by kind
Accessibility
What it does for you
- Plain text in a rounded label: nothing to operate, nothing announced beyond its words.
- One colour for every tag, from tokens set for light and dark.
- As a link it is an ordinary link, with the usual focus ring.
What you need to do
- Say what the tags are before them ("Good for"), or put them in a labelled list.
- For a tag that links, make its words say where it goes: "Family charters", not "Family".
- Never give a tag’s colour a meaning.
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves to a tag only if it is a link. |
| Enter | Follows the link. |
What a screen reader is told
- A plain tag: its words, as text.
- A linked tag: a link named by its words, and the number of items when they are in a list.
This is what the browser reports to assistive technology. What each screen reader then says varies, and has not been listened to yet.
WCAG 2.2
| Criterion | Level | How this meets it |
|---|---|---|
| 1.4.1 Use of Color | A | All tags are one colour; the words carry the meaning. |
| 2.4.4 Link Purpose (In Context) | A | A linked tag’s words say where it goes. |
| 4.1.2 Name, Role, Value | A | No role is claimed that it doesn’t have. |
The criteria this component has a part in. A page that uses it still has to meet the rest.
Checked
| Check | How | Result |
|---|---|---|
| Automated (axe-core) | WCAG 2.0, 2.1 and 2.2 rules at A and AA, the page in light and in dark | Passed Nothing found, light or dark |
| Narrow screen | No sideways scrolling at 320px wide (WCAG 1.4.10) | Passed No sideways scrolling |
| Keyboard and what the browser reports | Real key presses on the live example, and the role, name and state given to assistive technology | Passed 3 of 3 checks pass |
| On paper | Somnia’s print check: no overlaps, stranded headings or controls on the page | Passed No faults on 4 sheets |
| Screen reader | Listened to by a person, in VoiceOver and NVDA | Not yet Not yet checked by a person |
The 3 checks made with the keyboard, on the example at the top of this page:
- Passed A tag that is a link is reached by Tab and named by its words
- Passed A plain tag takes no focus: there is nothing to press
- Passed Tags that are links sit in a list, so their number is announced
Run by script on against Somnia DS 1.89.0, in Chromium with axe-core 4.14.0. How these checks work, and every component's results.
Not yet checked
- How it sounds in a screen reader (VoiceOver, NVDA, TalkBack) has not been checked by a person. The roles, names and states the browser reports are checked by script; what is actually spoken is not.
Evidence
Where it's used
| Where | For |
|---|---|
| Headland Yachting, yacht pages | "Good for": families, diving, first charters. On its staging site until launch. |
| Headland Yachting, charter pages and its yachts’ 404 page | Links to other kinds of charter. |
What we saw, and what changed
| When | What we saw | What changed |
|---|---|---|
| A yacht’s "Good for" line needed its items to stand apart from the sentence around them. | Small labels on their own colour tokens (1.39.0). | |
| Used as links, tags had no state of their own on hover. | A linked tag takes the accent on its edge when pointed at (1.77.0). |
From building and using it on real sites, each entry taken from the changelog or the build's own notes. This is observation by the studio and its clients, not research sessions with users.
What we don't know yet
- Whether the token build’s contrast check covers a tag’s words on its fill has not been confirmed. axe checks it on the pages that use tags.