DXC Logo
Halstack Design System
v16.1.0

Avatar

The Avatar component is a key visual element used to identify users, teams, or entities across the interface. It helps create a recognizable and consistent user experience by visually representing people or objects through images, icons, or initials.

Props

NameTypeDescriptionDefault
color'primary' | 'secondary' | 'tertiary' | 'success' | 'info' | 'neutral' |'warning' | 'error'Affects the visual style of the avatar. It can be used following semantic purposes or not.'neutral'
disabledbooleanIf true, the componente will be disabled.false
iconstring | SVGMaterial Symbol name or SVG element as the icon that will be placed as avatar.'person'
imageSrcstringURL of the image.-
labelstringText label associated with the avatar. Used to generate and display initials inside the avatar.-
linkHrefstringPage to be opened when the user clicks on the link.-
onClick() => voidThis function will be called when the user clicks the avatar. Makes it behave as a button.-
primaryTextstringText to be displayed as label next to the avatar.-
secondaryTextstringText to be displayed as sublabel next to the avatar.-
shape'circle' | 'square'This will determine if the avatar will be a rounded square or a circle.'circle'
size'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'Size of the component.'medium'
status
{ mode: 'default' | 'info' | 'success' | 'warning' | 'error'; position: 'top' | 'bottom'; }
Defines the color of the status indicator displayed on the avatar and where it will be placed. If not provided, no indicator will be rendered.-
tabIndexnumberValue of the tabindex attribute. It will only apply when the onClick or linkHref property is passed.0
titlestringText to be displayed inside a tooltip when hovering the avatar.-

Examples

Basic usage

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcAvatar
        label="Michael Ramirez"
        color="success"
        primaryText="Michael Ramirez"
        secondaryText="m.ramirez@insurance.com"
      />
    </DxcInset>
  );
}

Clickable

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcAvatar
        color="success"
        onClick={() => console.log("Hello")}
      />
    </DxcInset>
  );
}

Status

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcAvatar
        color="error"
        status={{mode: "success", position: "top"}}
      />
    </DxcInset>
  );
}

Tooltip

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcAvatar
        color="success"
        title="User Name"
      />
    </DxcInset>
  );
}