UserLabel

Maintainer:
DakEnviy
GitHub
view
type
avatar
text

UserLabel

The UserLabel component can be used to display users or user-related information.

Type

Used to manage avatar appearance. Use "person" for a personalized entity and "email", for an email address. If you do not need any avatar, use "empty".

Charles Darwin
email@example.com
Alan Turing
<UserLabel type="person" text="Charles Darwin" />
<UserLabel type="email" text="email@example.com" />
<UserLabel type="empty" text="Alan Turing" />

Avatar

This component can be used with a custom avatar. It only works with type: 'person'. You can provide an image, a property of the Avatar component, or a custom React node.

Charles Darwin
Charles Darwin
import {GraduationCap} from '@gravity-ui/icons';

<UserLabel type="person" avatar="<url>" text="Charles Darwin" />
<UserLabel type="person" avatar={{icon: GraduationCap}} text="Charles Darwin" />

Interactivity

This component is also interactive: it can be clickable or closable.

Charles Darwin
<UserLabel text="Charles Darwin" onClick={() => alert('onClick triggered')} />
<UserLabel text="Charles Darwin" onCloseClick={() => alert('onCloseClick triggered')} />

Properties

NameDescriptionTypeDefault
typeAvatar appearance'person' 'email' 'empty''person'
viewUserLabel view'outlined' 'clear''outlined'
sizeAvatar size'3xs' '2xs' 'xs' 's' 'm' 'l' 'xl''s'
avatarUser avatarAvatarProps string React.ReactElement
textVisible textReact.ReactNode
descriptionUser descriptionReact.ReactNode
onClickclick event handler for the componentFunction
onCloseClickclick event handler for the cross-icon buttonFunction
classNameCustom CSS class for the root elementstring
styleHTML style attributeReact.CSSProperties
qadata-qa HTML attribute, used for testingstring

CSS API

NameDescription
--g-user-label-sizeSize for avatar (width and height) and height for label
--g-user-label-border-radiusLabel border radius
--g-user-label-paddingLabel horizontal padding
--g-user-label-gapGap between elements (avatar, text, close icon)
--g-user-label-text-font-weightText font weight
--g-user-label-text-font-sizeText font size
--g-user-label-text-line-heightText line height
--g-user-label-description-font-weightDescription font weight
--g-user-label-description-font-sizeDescription font size
--g-user-label-description-line-heightDescription line height