Tag
Tags present static metadata or contextual information. They provide a fixed visual treatment, making them ideal for displaying system-defined values, attributes, or informational labels.
import {Tag} from "@qualcomm-ui/react/tag"Examples
Icons
Icons are supplied using the startIcon and endIcon props.
<Tag emphasis="neutral" startIcon={Plus}>
Label
</Tag>
<Tag emphasis="neutral" endIcon={Plus}>
Label
</Tag>
Variants
A tag renders as one of four types:
- read-only (default) renders static metadata.
- dismissable adds a close button. Set variant to
dismissableand pair it with the dismiss callback. - selectable renders as a toggle
<button>. Set variant toselectable. - link renders the tag as an anchor. Use the render prop to supply
<Link to="…" />or<a href="…" />. Setaria-currenton the active anchor for accessibility. The optional active prop applies the current-item styling.
<Tag>read-only</Tag>
<Tag variant="dismissable">dismissable</Tag>
<Tag variant="selectable">selectable</Tag>
<Tag render={<Link to="/" />}>link</Tag>
<Tag active render={<Link aria-current="true" to="/components/tag" />}>
active link
</Tag>
Controlled State
Set the initial value using the defaultSelected prop, or use selected and onSelectedChange to control the value manually. These props follow our controlled state pattern. Only applicable when variant is selectable.
import {type ReactElement, useState} from "react"
import {Check, Plus, Star} from "lucide-react"
import {Tag} from "@qualcomm-ui/react/tag"
export function TagControlledDemo(): ReactElement {
const [selected, setSelected] = useState<boolean>(false)
return (
<div className="flex flex-col items-start gap-2">
<Tag
endIcon={<Star />}
onSelectedChange={setSelected}
selected={selected}
size="lg"
startIcon={selected ? Check : Plus}
variant="selectable"
>
{selected ? "Subscribed" : "Subscribe"}
</Tag>
</div>
)
}Colors
Control the visual emphasis with different colors via the emphasis prop. The default emphasis is outline-brand.
<Tag emphasis="outline-brand" startIcon={Smile} variant="selectable">
outline-brand
</Tag>
<Tag emphasis="outline-neutral" startIcon={Smile} variant="selectable">
outline-neutral
</Tag>
<Tag emphasis="neutral" startIcon={Smile} variant="selectable">
neutral
</Tag>
<Tag emphasis="blue" startIcon={Smile} variant="selectable">
blue
</Tag>
<Tag emphasis="cyan" startIcon={Smile} variant="selectable">
cyan
</Tag>
<Tag emphasis="teal" startIcon={Smile} variant="selectable">
teal
</Tag>
<Tag emphasis="lime" startIcon={Smile} variant="selectable">
lime
</Tag>
<Tag emphasis="green" startIcon={Smile} variant="selectable">
green
</Tag>
<Tag emphasis="yellow" startIcon={Smile} variant="selectable">
yellow
</Tag>
<Tag emphasis="amber" startIcon={Smile} variant="selectable">
amber
</Tag>
<Tag emphasis="orange" startIcon={Smile} variant="selectable">
orange
</Tag>
<Tag emphasis="red" startIcon={Smile} variant="selectable">
red
</Tag>
<Tag emphasis="magenta" startIcon={Smile} variant="selectable">
magenta
</Tag>
<Tag emphasis="violet" startIcon={Smile} variant="selectable">
violet
</Tag>
<Tag emphasis="purple" startIcon={Smile} variant="selectable">
purple
</Tag>
Sizes
Choose from four sizes: sm, md, lg, and xl. The default size is md.
<Tag size="sm" variant="dismissable">
Label
</Tag>
<Tag size="md" variant="dismissable">
Label
</Tag>
<Tag size="lg" variant="dismissable">
Label
</Tag>
<Tag size="xl" variant="dismissable">
Label
</Tag>
States
Disable the tag by setting the disabled prop.
<Tag variant="dismissable">Label</Tag>
<Tag disabled variant="dismissable">
Label
</Tag>
Shape
Control the shape of the tag with the shape prop. The default shape is square.
<Tag shape="square">Label</Tag>
<Tag shape="rounded">Label</Tag>
API
<Tag>
booleanbooleantrue, the component becomes
unresponsive to input and is visually dimmed to indicate its disabled state.| 'outline-brand'
| 'outline-neutral'
| 'neutral'
| 'amber'
| 'blue'
| 'cyan'
| 'green'
| 'lime'
| 'magenta'
| 'orange'
| 'purple'
| 'red'
| 'teal'
| 'violet'
| 'yellow'
| 'kiwi'
| LucideIcon
| ReactNode
ReactElement for additional
customization.
Ignored when variant is dismissable, as it is reserved for the
dismiss icon.() => void
dismissable.(
selected: boolean,
) => void
selectable.| ReactElement
| ((
props: object,
) => ReactElement)
booleanselectable.| 'square'
| 'rounded'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| LucideIcon
| ReactNode
ReactElement for additional
customization.| 'selectable'
| 'dismissable'
| 'link'
| {
'aria-disabled'?:
| 'true'
| 'false'
| undefined
className: 'qui-tag__root'
'data-active'?: ''
'data-disabled': ''
'data-emphasis':
| 'outline-brand'
| 'outline-neutral'
| 'neutral'
| 'amber'
| 'blue'
| 'cyan'
| 'green'
| 'lime'
| 'magenta'
| 'orange'
| 'purple'
| 'red'
| 'teal'
| 'violet'
| 'yellow'
| 'kiwi'
'data-selected': ''
'data-shape':
| 'square'
| 'rounded'
'data-size':
| 'sm'
| 'md'
| 'lg'
| 'xl'
'data-tag-part': 'root'
'data-variant'?:
| 'selectable'
| 'dismissable'
| 'link'
tabIndex?: -1
}
| {
'aria-disabled'?:
| 'true'
| 'false'
| undefined
'aria-pressed'?:
| 'true'
| 'false'
| undefined
className: 'qui-tag__root'
'data-disabled': ''
'data-emphasis':
| 'outline-brand'
| 'outline-neutral'
| 'neutral'
| 'amber'
| 'blue'
| 'cyan'
| 'green'
| 'lime'
| 'magenta'
| 'orange'
| 'purple'
| 'red'
| 'teal'
| 'violet'
| 'yellow'
| 'kiwi'
'data-selected': ''
'data-shape':
| 'square'
| 'rounded'
'data-size':
| 'sm'
| 'md'
| 'lg'
| 'xl'
'data-tag-part': 'root'
'data-variant'?:
| 'selectable'
| 'dismissable'
| 'link'
tabIndex?: -1
}
StartIcon
className'qui-tag__icon'data-tag-part'start-icon'EndIcon
Note that the endIcon prop is ignored when variant is dismissible.
className'qui-tag__icon'data-tag-part'end-icon'