A tag group is a list of labels, categories, keywords, filters, or other items, that can be used to group and filter content.
import { TagGroup, Tag } from '@backstage/ui';
<TagGroup>
<Tag>Tag 1</Tag>
<Tag>Tag 2</Tag>
</TagGroup>A tag group is a list of tags.
| Prop | Type | Default | Responsive |
|---|---|---|---|
| disabledKeys | Iterable<Key> | - | No |
| selectionMode | nonesinglemultiple | - | No |
| selectedKeys | allIterable<Key> | - | No |
| defaultSelectedKeys | allIterable<Key> | - | No |
| onRemove | (keys: Set<Key>) => void | - | No |
| onSelectionChange | (keys: Selection) => void | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
A tag is a single item in a tag group.
| Prop | Type | Default | Responsive |
|---|---|---|---|
| id | string | - | No |
| textValue | string | - | No |
| isDisabled | boolean | - | No |
| href | string | - | No |
| icon | ReactNode | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
A tag can be a link by passing a href prop.
<TagGroup>
<Tag href="/items/banana">Banana</Tag>
<Tag href="/items/apple">Apple</Tag>
<Tag href="/items/orange">Orange</Tag>
</TagGroup>A tag can have an icon by passing a icon prop.
<TagGroup>
<Tag icon={<RiBugLine />}>Banana</Tag>
<Tag icon={<RiAccountCircleLine />}>Apple</Tag>
<Tag icon={<RiEyeLine />}>Orange</Tag>
<Tag icon={<RiHeartLine />}>Pear</Tag>
</TagGroup>A tag can have a size by passing a size prop. It could be small or medium.
<Flex direction="column">
<TagGroup>
<Tag size="small" icon={<RiBugLine />}>Banana</Tag>
<Tag size="small" icon={<RiAccountCircleLine />}>Apple</Tag>
</TagGroup>
<TagGroup>
<Tag size="medium" icon={<RiBugLine />}>Banana</Tag>
<Tag size="medium" icon={<RiAccountCircleLine />}>Apple</Tag>
</TagGroup>
</Flex>A tag can be removed by passing a onRemove prop.
const list = useListData({
initialItems: [
{ id: 'banana', name: 'Banana' },
{ id: 'apple', name: 'Apple' },
{ id: 'orange', name: 'Orange' },
],
});
<TagGroup
items={list.items}
onRemove={keys => list.remove(...keys)}
>
{item => <Tag>{item.name}</Tag>}
</TagGroup>A switch can be disabled using the isDisabled prop.
<TagGroup>
<Tag>Banana</Tag>
<Tag isDisabled>Apple</Tag>
<Tag isDisabled>Orange</Tag>
<Tag>Pear</Tag>
</TagGroup>Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-TagGroupbui-TagListbui-Tagbui-TagIconbui-TagRemoveButton0.9.0 - BREAKING: Changed className prop behavior to augment default styles instead of being ignored or overriding them.Affected components:
If you were passing custom className values to any of these components that relied on the previous behavior, you may need to adjust your styles to account for the default classes now being applied alongside your custom classes. #31496
0.5.0 - New Switch component #30251