---
title: Tags
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Tags, StackView, PreviewCard } from '@telus-uds/components-web'
import { Tags as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Tags

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D988%253A7565" />

```jsx live
<Tags
  items={[
    { label: 'First tag', id: 'first' },
    { label: 'Second tag', id: 'second' },
    { label: 'Third tag', id: 'third' },
    { label: 'Fourth tag', id: 'fourth' },
    { label: 'Fifth tag', id: 'fifth' }
  ]}
/>
```

## Introduction

Tags allows the selection of one or more items, typically used for filtering content.

Spacing between buttons increases on wider viewports (`lg` and `xl`).

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

Tags should have very simple, short labels, ideally one word or two.

### `maxValues` prop

The prop `maxValues` may be passed a number to limit how many items are selelcted.

By default, any number of tags may be selected.

```jsx live
<Tags
  items={[
    { label: 'First tag', id: 'first' },
    { label: 'Second tag', id: 'second' },
    { label: 'Third tag', id: 'third' },
    { label: 'Fourth tag', id: 'fourth' },
    { label: 'Fifth tag', id: 'fifth' }
  ]}
  maxValues={2}
/>
```

### `onChange` prop

An `onChange` function may be provided, which is called when a Tags item is toggled.

```jsx live
<Tags
  items={[
    { label: 'First tag', id: 'first' },
    { label: 'Second tag', id: 'second' },
    { label: 'Third tag', id: 'third' },
    { label: 'Fourth tag', id: 'fourth' },
    { label: 'Fifth tag', id: 'fifth' }
  ]}
  onChange={(state) => setTimeout(() => alert(`Tags has selected: ${state}`), 100)}
/>
```

### Controlled usage with `values` prop

Pass an array of item ids to the `values` prop as well as `onChange` to control the Tags from a parent.

This is usually the easiest way to control subsequent lists of content with Tags.

### Accessibility

`Tags` buttons will be treated like checkboxes by accessibility tools; unless `maxValues` is set to `1`, in
which case they will be treated like radio buttons.

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Tags" />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="Tags" />
