Tags are used to label and filter content in an interface.
The tag component provides a method to label and categorise content in an interface. They enable the user to enable the user to sort, filter or otherwise change the content being displayed, to more easily find what they need.
They are useful for dense or content-rich contexts like:
Tags can also be hyperlinked, to help the user navigate to other content.
Each tag has:
Multiple tags grouped together are arrayed horizontally, and can also display:
Design system components are published in a Figma library. Install the library and add it to your project to start using this component.
Tags are useful for providing additional context for a list of options, and enabling a user to remove or hide non-relevant content. They should be used as a secondary sorting and filtering tool, not as a primary method of navigating content.
Avoid displaying long lists of tags, as they can clutter an interface and make navigating content confusing.
By default, the tag component supports displaying up to 8 tags. If you have more than 8 tags, consider revisiting how you're organising your content.
The tag component has two subcomponents in Figma, each with their own set of controls:
Control | Options | Description |
---|---|---|
State |
|
Toggles between different interaction states |
Colour |
|
Toggles tag colour. 8 predefined colourways are included as a starting point. |
Icon |
|
Toggles on/off an icon on the left of the tag |
Closeable |
|
Defines whether a tag is closable/removable. Toggles on/off a 'close' icon on the right of the tag |
Tag text |
|
Sets label text for the tag |
Control | Options | Description |
---|---|---|
State |
|
Toggles between different interaction states |
Colour |
|
Toggles tag colour. 8 predefined colourways are included as a starting point. |
Detailed technical documentation, interactive previews and code samples are published in the B.C. Design System Storybook.
A reference implementation of the tag component in React is published in the BCDS React components library. Install the package via npm to start using the component.
The tag component is a styled version of the React Aria TagGroup component. It relies on the TagList and Tag subcomponents.
Refer to the React Aria documentation for detailed information about:
You can configure a group of tags to allow the user to select a single or multiple options. You can also set individual tags to be selected by default, or disable them entirely.
Selection behaviour is disabled if a tag is hyperlinked.
These summaries reflect the component used as provided. If you modify it, confirm that your changes comply with the Web Content Accessibility Guidelines (WCAG). B.C. government digital services are required to meet the WCAG Level AA standard.
Requirement | WCAG Success Criterion | Validation |
---|---|---|
Make sure colour isn't the only way you convey information | 1.4.1 (Level A) |
Tags have a distinctive shape and rounded corners to differentiate them within the user interface |
Enhance visual contrast for user interface and graphics | 1.4.11 (Level AA) |
Tag fill and text colours exceed 4.5:1 contrast ratio in all states (except 'Disabled', which is exempt from SC 1.4.11) |
Let people choose how they navigate content | 2.4.5 (Level AA) |
Tags can be navigated, selected and deselected using the keyboard |
Show where the keyboard is active on the screen | 2.4.7 (Level AA) |
Tag focus state is indicated by an offset border ring |
Use consistent names in labels | 2.5.3 (Level AA) |
Tags have a visible text label, and supports semantic labelling via the aria-label property |
Make sure interaction or click targets meet a minimum size | 2.5.8 (Level AA) |
Tags have a minimum target area of 32px by 32px |
Ensure user interface components behave predictably | 3.2.1 (Level A) | Tags are not selected or deselected automatically on focus |
Make sure components can be read and used by assistive technology | 4.1.2 (Level A) |
Tags are grouped and labelled using aria-labelledby attributes |