Label

관리자:
korvin89
GitHub
theme
type
size
disabled
interactive
value
copyText
children

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.

import {Label} from '@gravity-ui/uikit';

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.

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.

Icon

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

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:

State

A label can have different states:

  • disabled: No interactions allowed.
  • interactive: Makes the label hoverable.
  • loading: Shows a loading state.

Size

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 effect. Note: cannot be turned off for copy and info labels.boolean
loadingLoading statebooleanfalse
onClickclick event handlerFunction
onCloseClickClose button click event handlerFunction
onCopycopy event handlerFunction
qadata-qa HTML attribute, used for testingstring
sizeLabel size"2xs" "xs" "s" "m""xs"
themeLabel themestring"normal"
titletitle HTML attributestring
typeLabel type"default" "copy" "close" "info""default"
valueLabel value (displayed as "children : value")React.ReactNode
widthControls how Label uses parent's space"auto"