Label

Maintainer:
goshander
GitHub
theme
type
size
disabled
interactive
value
copyText
children
import {Label} from '@gravity-ui/uikit';

You can use Labels for highlighting certain information. A Label with the Close or Copy button may be useful for various simple actions.

Labels are most suitable for displaying one-line text information with different color codes that show its importance.

Appearance

A Label can be displayed in multiple styles.

Theme

Use the theme property to apply different themes for various statuses. You can use the following values: normal, info, success, warning, danger, utility, unknown, and clear. The default theme is normal.

Normal
Info
Success
Warning
Danger
Utility
Unknown
Clear
<Label theme="normal">Normal</Label>
<Label theme="info">Info</Label>
<Label theme="success">Success</Label>
<Label theme="warning">Warning</Label>
<Label theme="danger">Danger</Label>
<Label theme="utility">Utility</Label>
<Label theme="unknown">Unknown</Label>
<Label theme="clear">Clear</Label>

Type

The type property adds various options to a Label:

copy: Adds a copy button; when clicked, it copies the value of the copyText property.

close: Adds a close button for managing label lists.

info: Adds an info icon to the label.

Closable
Copy
Info
<Label type="default" onClick={() => alert('On click label')} size="s">Clickable</Label>
<Label type="close" onCloseClick={() => alert('On click close')} size="s">Closable</Label>
<Label type="copy" copyText="Copy" onCopy={() => alert('On copy')} size="s">Copy</Label>
<Label type="info" size="s">Info</Label>

Icon

You can add an icon with the icon property. To do so, use the Icon component, which is a special wrapper for SVGs.

Icon
Icon and close
Icon and copy
<Label icon={<Icon size={16} data={GearIcon} />}>Icon</Label>
<Label type="close" icon={<Icon size={16} data={GearIcon} />}>Icon and close</Label>
<Label type="copy" icon={<Icon size={16} data={GearIcon} />}>Icon and copy</Label>

Value

You can use Labels for displaying key-value information. For that, you need to provide the key to the children poperty, and value, to value:

Key
:
Value
Key
:
Value
Key
:
Value
Key
:
Value
Key
:
Value
Key
:
Value
Key
:
Value
Key
:
Value
<Label theme="normal" value="Value">Key</Label>
<Label theme="info" value="Value">Key</Label>
<Label theme="success" value="Value">Key</Label>
<Label theme="warning" value="Value">Key</Label>
<Label theme="danger" value="Value">Key</Label>
<Label theme="utility" value="Value">Key</Label>
<Label theme="unknown" value="Value">Key</Label>
<Label theme="clear" value="Value">Key</Label>

State

A label can have different states:

  • disabled: No interactions allowed.
  • interactive: Makes the label hoverable.
Default
Disabled
Interactive
<Label>Default</Label>
<Label disabled>Disabled</Label>
<Label interactive>Interactive</Label>

Size

XS size
S size
M size
<Label size="xs">XS size</Label>
<Label size="s">S size</Label>
<Label size="m">M size</Label>

Properties

NameDescriptionTypeDefault
childrenContentReact.ReactNode
classNameclass HTML attributestring
closeButtonLabelaria-label of the close buttonstring
copyButtonLabelaria-label of the copy buttonstring
copyTextText to copystring
disabledDisabled stateboolean
iconLabel icon (on the left)React.ReactNode
interactiveEnables hover effectboolean
onClickclick event handlerFunction
onCloseClickClose button click event handlerFunction
onCopycopy event handlerFunction
sizeLabel size"xs" "s" "m""s"
themeLabel themestring"normal"
typeLabel type"default" "copy" "close" "info""default"
valueLabel value (displayed as "children : value")string
titletitle HTML attributestring
qadata-qa HTML attribute, used for testingstring