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:
_10import { Tag, TagIcon, TagText, TagGroup } from '@ef-global/backpack/Tag';
Props
| Name | Type | Default | Required | Description |
| tagType | 'label' | 'button' | 'label' | Yes | Determines if the tag is a label or a button. |
| value | string | Yes | The value associated with the tag. | |
| small | boolean | false | No | Whether the tag is small or not. |
| filled | boolean | false | No | Whether the label tag is filled or not. |
| removable | boolean | false | No | Whether the label tag is removable or not. |
| disabled | boolean | false | No | Whether the button tag is disabled or not. |
| inverse | boolean | false | No | Whether the tag is styled for a dark background or not. |
| onClick | React.MouseEventHandler | No | A function to be called when the tag is clicked. | |
| onKeyDown | React.KeyboardEventHandler | No | A function to be called when a key is pressed down while the tag has focus. | |
| className | string | No | A custom classname to be added to the tag. | |
| children | React.ReactNode | No | The 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
| Prop | Type | Default | Description |
| inverse | boolean | false | If true, the TagGroup will have an inverted appearance. |
| align | TagGroupAlign | 'start' | Determines the alignment of tags within the TagGroup. One of 'start', 'center', 'end', 'stretch'. |
| disabled | boolean | false | If true, all tags within the TagGroup will be disabled. |
| className | string | Additional CSS class applied to the TagGroup component. | |
| children | React.ReactNode | The tags to be rendered within the TagGroup. | |
| ...rest | ToggleGroupMultipleProps | Any 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
| Name | Type | Default | Required | Description |
| icon | React.ReactNode | Yes | The 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
| Name | Type | Default | Required | Description |
| children | React.ReactNode | Yes | The text content to be displayed in the tag. |
Usage
_10<Tag tagType="label" value="Label">_10 <TagText>_10 Custom Text_10 </TagText>_10</Tag>