3.0.2 • Published 5 days ago

@lg-chat/avatar v3.0.2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
5 days ago

Avatar

Installation

Yarn

yarn add @lg-chat/avatar

NPM

npm install @lg-chat/avatar

Example

import { Avatar } from '@lg-chat/avatar';

return <Avatar darkMode variant={Variant.Mongo} />;

Output HTML

<div class="lg-ui-lg-message-avatar-0000">
  <div class="leafygreen-ui-i5hsjh" data-testid="mongo-avatar">
    <svg
      role="img"
      aria-label="MongoDB Logo"
      class="leafygreen-ui-ebwjgf"
      height="40"
      viewBox="0 0 15 32"
      fill="none"
    >
      <path />
    </svg>
  </div>
</div>

Properties

PropTypeDescriptionDefault
darkModebooleanDetermines if the component will render in dark modefalse
namestringThe name of the user who is represented by the avatar. The rendered text will be the initials of the text passed to this prop.
size"small", "default"Determines the size of the avatar"default"
sizeOverridenumberIf provided, overrides the size prop to a customizable number (in px)
variant"mongo", "user", "default"Determines the Avatar component's variant"default"
...HTMLElementProps<'div'>Props spread on the root element

Behavior

  • When variant = "user" and a value is not passed to the name prop, an Avatar with the Person icon will be rendered as a fallback.
  • The size prop is given default values responsinve to the chat container size. The chat container size is determined by the width of the first child in LeafyGreenChatContext. If a size prop value is provided, however, it will override the default values.