Skip to content
Autumn 2026 Mesh Release and Design Tokens v2 now available! Read the announcement

The Tag component is used to help users quickly recognise categories in content or allow a user to organise items using keywords. Tags can also be used as a method of filtering data, to show only items within a particular category.

Installation

bash
npm install @nib-group/mesh-tag

Usage

jsx
import Tag from '@nib-group/mesh-tag';

Interactive demo

jsx
<Stack space={2}>
  <Inline space={2}>
    <Tag variation="success">Tag</Tag>
    <Tag variation="error">Tag</Tag>
    <Tag variation="warning">Tag</Tag>
    <Tag variation="info">Tag</Tag>
    <Tag variation="brand">Tag</Tag>
    <Tag variation="default">Tag</Tag>
    <Tag variation="prominent">Tag</Tag>
    <Tag variation="gentle">Tag</Tag>
    <Tag variation="muted">Tag</Tag>
  </Inline>
  {/* Mode based equivalents */}
  <Inline space={2}>
    <Tag sentiment="positive" prominence="prominent">
      Tag
    </Tag>
    <Tag sentiment="negative" prominence="prominent">
      Tag
    </Tag>
    <Tag sentiment="cautionary" prominence="prominent">
      Tag
    </Tag>
    <Tag sentiment="informative" prominence="prominent">
      Tag
    </Tag>
    <Tag sentiment="hero">Tag</Tag>
    <Tag sentiment="default">Tag</Tag>
    <Tag sentiment="default" prominence="prominent">
      Tag
    </Tag>
    <Tag sentiment="default" prominence="gentle">
      Tag
    </Tag>
    <Tag sentiment="default" prominence="muted">
      Tag
    </Tag>
    {/* Extras */}
    <Tag sentiment="sage">Tag</Tag>
    <Tag sentiment="warm">Tag</Tag>
    <Tag sentiment="sunset">Tag</Tag>
  </Inline>
</Stack>

Props

PropTypeDefaultDescription
variationstringThe variation of the tag which determines the tag colors. Must be one of default, prominent, gentle, muted, brand, success, info, warning or error. This prop takes precedence over, and will override the sentiment and prominence props.
sentimentstring or objectThe sentiment to use. Must be a valid sentiment for the active brand, or an object with brands as keys and sentiments as values. If variation is provided, this prop will be overridden.
prominencestring or objectThe prominence to use. Must be one of [default, muted, gentle, prominent], or an object with brands as keys and prominences as values. If variation is provided, this prop will be overridden.
sizestringdefaultThe size of the tag. Must be one of small or default.
backgroundstringdefaultThe background color of the tag. See theme colorValues for valid options.
foregroundstringdefaultThe color of the tag text. See theme colorValues for valid options.
asstringThe underlying HTML element for the tag
childrennodeThe children of the tag.

Color

There are a few ways to set the color of a tag. The simplest way is to use the variation prop, which provides predefined styles for common use cases. If the variation prop is set, sentiment and prominence props will be ignored!

When you need finer control over the tag colors, you can instead set the sentiment and prominence props. For example you may want to increase the prominence of a tag with a negative sentiment to make it more eye-catching:

jsx
<Inline space={2}>
  <Tag variation="error">Error variation</Tag>
  <Tag sentiment="negative" prominence="prominent">
    Negative/prominent sentiment
  </Tag>
</Inline>

Note the difference in naming between variation and sentiment/prominence. The variation prop uses more descriptive names to indicate the use case of the tag, whereas the sentiment and prominence props use the underlying theme values for sentiment and prominence.

Finally, you can also set the foreground prop to adjust the tag text color. For example you may want a neutral tag background with a brand foreground to add emphasis to the tag text:

jsx
<Tag sentiment="default" prominence="gentle" foreground="brand">
  Default/gentle bg with brand fg
</Tag>

Typography

It’s recommend not to capitalise tags. Labels should use sentence-style capitalisation. Keep labels to one line of concise text.

Size

Tags come in two sizes, small and medium. Try to use the default size whenever possible. Width of tags varies based on content width. Spacing between tags in a single line should be .5rem or 8px.

Behaviour

We recommend using the variation prop whenever possible, as it provides predefined styles for common use cases. The background and foreground props should only be used when no suitable variation is available.

Tags don’t support actions. For example a user cannot click, close or hover over a tag.

If a product team requires iteration with tags, please raise an issue or contact the designops team.

Accessibility

Because tags don’t have interation requirements. They don’t support focus, removal with a delete/backspace key or tab navigation.

Aria-labels should be applied to describe what the list of options are to the user. aria-orientation="horizontal" should be applied to a container of tags to describe the left to right direction of the tags.