Backpack UI
Components
Tags

Tags

Tag

The Tag component is a versatile UI element that can be used as a standalone LabelTag or as part of a TagGroup. The Tag can have a TagIcon and/or a TagText as children.

When using a ButtonTag, it must be wrapped within a ButtonGroup.



Importing

To use the Tag component and its related components, you'll need to import them:


_10
import { Tag, TagIcon, TagText, TagGroup } from '@ef-global/backpack/Tag';

Props

NameTypeDefaultRequiredDescription
tagType'label' | 'button''label'YesDetermines if the tag is a label or a button.
valuestringYesThe value associated with the tag.
smallbooleanfalseNoWhether the tag is small or not.
filledbooleanfalseNoWhether the label tag is filled or not.
removablebooleanfalseNoWhether the label tag is removable or not.
disabledbooleanfalseNoWhether the button tag is disabled or not.
inversebooleanfalseNoWhether the tag is styled for a dark background or not.
onClickReact.MouseEventHandlerNoA function to be called when the tag is clicked.
onKeyDownReact.KeyboardEventHandlerNoA function to be called when a key is pressed down while the tag has focus.
classNamestringNoA custom classname to be added to the tag.
childrenReact.ReactNodeNoThe content to be displayed inside the tag. Generally used for customizing appearance.

Usage

LabelTag

To create a LabelTag, you can use the Tag component with the tagType prop set to 'label' and a value set. You can also use the TagIcon and TagText subcomponents to customize the content of the tag.



_10
<Tag tagType="label" value="tag">
_10
<TagIcon>
_10
<IconAirplane />
_10
</TagIcon>
_10
<TagText>Example LabelTag</TagText>
_10
</Tag>

ButtonTag

To create a ButtonTag, use the Tag component with the tagType prop set to 'button' and the value prop set to a unique string. You can also use the TagIcon and TagText subcomponents to customize the content of the tag.



_11
<TagGroup type="multiple">
_11
<Tag tagType="button" as="button" value="tag1">
_11
<TagIcon>
_11
<IconBalloon />
_11
</TagIcon>
_11
<TagText>Example ButtonTag 1</TagText>
_11
</Tag>
_11
<Tag tagType="button" as="button" value="tag2">
_11
<TagText>Example ButtonTag 2</TagText>
_11
</Tag>
_11
</TagGroup>

Customizing appearance

You can use the variant and size props to customize the appearance of label tags. The variant prop accepts values such as 'default', 'outlined', and 'filled'. The size prop accepts values such as 'small', 'medium', and 'large'.



_26
<TagGroup type='multiple'>
_26
<Tag tagType='label' small={true} value='tag1'>
_26
<TagIcon>
_26
<IconBurger />
_26
</TagIcon>
_26
<TagText>Small Outlined</TagText>
_26
</Tag>
_26
<Tag tagType='label' small={true} filled={true} value='tag1'>
_26
<TagIcon>
_26
<IconBurger />
_26
</TagIcon>
_26
<TagText>Small Filled</TagText>
_26
</Tag>
_26
<Tag tagType='label' value='tag2'>
_26
<TagIcon>
_26
<IconBurger />
_26
</TagIcon>
_26
<TagText>Regular Outlined</TagText>
_26
</Tag>
_26
<Tag tagType='label' filled={true} value='tag2'>
_26
<TagIcon>
_26
<IconBurger />
_26
</TagIcon>
_26
<TagText>Regular Filled</TagText>
_26
</Tag>
_26
</TagGroup>

TagGroup

The TagGroup component is used to group multiple tags together. It ensures proper spacing and alignment of the tags within the group.

Props

PropTypeDefaultDescription
inversebooleanfalseIf true, the TagGroup will have an inverted appearance.
alignTagGroupAlign'start'Determines the alignment of tags within the TagGroup. One of 'start', 'center', 'end', 'stretch'.
disabledbooleanfalseIf true, all tags within the TagGroup will be disabled.
classNamestringAdditional CSS class applied to the TagGroup component.
childrenReact.ReactNodeThe tags to be rendered within the TagGroup.
...restToggleGroupMultiplePropsAny additional props passed will be forwarded to the underlying radix-ui ToggleGroup.Root component.

Usage


_10
<TagGroup type="multiple">
_10
<Tag tagType="label" value="Label 1" />
_10
<Tag tagType="label" value="Label 2" />
_10
<Tag tagType="button" as="button" value="Button 1" />
_10
</TagGroup>

TagIcon

The TagIcon component is used to add an icon to the tag.

Props

NameTypeDefaultRequiredDescription
iconReact.ReactNodeYesThe icon to be displayed inside the tag.

Usage


_10
<Tag tagType="label" value="Label">
_10
<TagIcon icon={<MdLabel />} />
_10
</Tag>

TagText

The TagText component is used to customize the text appearance inside the tag. You can use this component to apply custom styling or to include other text-related components.

Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodeYesThe text content to be displayed in the tag.

Usage


_10
<Tag tagType="label" value="Label">
_10
<TagText>
_10
Custom Text
_10
</TagText>
_10
</Tag>