Components

Tag

Use the tag component to show users the status of something.

Completed
<strong class="govuk-tag"> Completed </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 option 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 option 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 "moduk/components/tag/macro.njk" import modukTag -%}

{{ modukTag({
text: "Completed"
}) -}}

See GOV.UK tag component guidance for:

  • when to use this component
  • how it works
  • using colour with tags

Additional colours

If you need more tag colours, you can use the following tints.

Class nameTag
govuk-tag--grey Inactive
govuk-tag--green New
govuk-tag--turquoise Active
govuk-tag--blue Pending
govuk-tag--purple Received
govuk-tag--pink Sent
govuk-tag--red Rejected
govuk-tag--orange Declined
govuk-tag--yellow Delayed
<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Class name</th>
<th scope="col" class="govuk-table__header">Tag</th>
</tr>
</thead>
<tbody class="govuk-table__body">
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--grey</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--grey"> Inactive </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--green</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--green"> New </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--turquoise</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--turquoise"> Active </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--blue</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--blue"> Pending </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--purple</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--purple"> Received </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--pink</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--pink"> Sent </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--red</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--red"> Rejected </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--orange</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--orange"> Declined </strong>
</td>
</tr>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<code class="guidance-inline-code">govuk-tag--yellow</code>
</td>
<td class="govuk-table__cell">
<strong class="govuk-tag govuk-tag--yellow"> Delayed </strong>
</td>
</tr>
</tbody>
</table>
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 option 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 option 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 "moduk/components/tag/macro.njk" import modukTag -%}
{% from "moduk/components/table/macro.njk" import modukTable -%}

{{ modukTable({
head: [
{
text: "Class name"
},
{
text: "Tag"
}
],
rows: [
[
{
html: "<code class='guidance-inline-code'>govuk-tag--grey</code>"
},
{
html: modukTag({
text: "Inactive",
classes: "govuk-tag--grey"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--green</code>"
},
{
html: modukTag({
text: "New",
classes: "govuk-tag--green"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--turquoise</code>"
},
{
html: modukTag({
text: "Active",
classes: "govuk-tag--turquoise"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--blue</code>"
},
{
html: modukTag({
text: "Pending",
classes: "govuk-tag--blue"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--purple</code>"
},
{
html: modukTag({
text: "Received",
classes: "govuk-tag--purple"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--pink</code>"
},
{
html: modukTag({
text: "Sent",
classes: "govuk-tag--pink"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--red</code>"
},
{
html: modukTag({
text: "Rejected",
classes: "govuk-tag--red"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--orange</code>"
},
{
html: modukTag({
text: "Declined",
classes: "govuk-tag--orange"
})
}
],
[
{
html: "<code class='guidance-inline-code'>govuk-tag--yellow</code>"
},
{
html: modukTag({
text: "Delayed",
classes: "govuk-tag--yellow"
})
}
]
]
}) -}}

Changes from the GOV.UK version

MOD.UK Design System components are closely based on GOV.UK Design System components.

For this component we’ve changed the font and the colours.

Have you tested this component?

Let us know how we could improve this component or share your user research findings.

Email the MOD.UK Design System team at design-system@digital.mod.uk

Need help?

Email the MOD.UK Design System team at design-system@digital.mod.uk if you have questions or feedback.