Components

Tag

<strong class="govuk-tag">
  alpha
</strong>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
text string Required. If html is set, this is not required. Text to use within the tag component. If html is provided, the text argument will be ignored.
html string Required. If text is set, this is not required. HTML to use within the tag component. If html is provided, the text argument will be ignored.
classes string Classes to add to the tag.
attributes object HTML attributes (for example data attributes) to add to the tag.
{%- from "govuk/components/tag/macro.njk" import govukTag -%}

{{ govukTag({
  text: "alpha"
}) }}

When to use this component

Use the tag component to indicate the status of something, such as an item on a task list or a phase banner.

How it works

There are 2 ways to use the tag component. You can use HTML or, if you are using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.

<strong class="govuk-tag">
  alpha
</strong>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
text string Required. If html is set, this is not required. Text to use within the tag component. If html is provided, the text argument will be ignored.
html string Required. If text is set, this is not required. HTML to use within the tag component. If html is provided, the text argument will be ignored.
classes string Classes to add to the tag.
attributes object HTML attributes (for example data attributes) to add to the tag.
{%- from "govuk/components/tag/macro.njk" import govukTag -%}

{{ govukTag({
  text: "alpha"
}) }}

Help improve this page

To help make sure the Tag page is useful, relevant and up to date, you can:

Need help?

If you’ve got a question about the GOV.UK Design System you can contact the team: