Avatar

Avatar is a component that displays a user's profile picture or initials. It can be customized with props like size, shape, background color, and image source. If no image source is provided, it will display the user's initials. This component is typically used in user profile pages, comment sections, or messaging applications.

import { Avatar } from '@lobehub/ui';

Default

cm

ReactNode

Emoji

📺

APIs

NameDescriptionTypeDefault
animation--boolean--
avatarThe URL or base64 data of the avatar imagestring|ReactNode--
backgroundThe background color of the avatarstring--
shapeThe shape of the avatar"circle"|"square""circle"
sizeThe size of the avatar in pixelsnumber40
titleThe title text to display if avatar is not providedstring--
unoptimized--boolean--
gap--number--
srcSrc of image avatarReactNode--
srcSetSrcset of image avatarstring--
draggable--boolean|true|false--
iconIcon to be used in avatarReactNode--
style--{}--
prefixCls--string--
className--string--
rootClassName--string--
children--ReactNode--
alt--string--
crossOrigin--""|"anonymous"|"use-credentials"--
onClick--(e?:React.MouseEvent<HTMLElement, MouseEvent>)=>void--
onError--()=>boolean--
refAllows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).|string|bivarianceHack|RefObject<T>--
key--Key|--