Avatar

A picture of someone at the button's heights, with initials standing in until it loads or when it can't.

01Preview

01
Full screen
APAPAPAP
LN

Initials stand in when there is no picture or it fails to load.

02Installation

npx shadcn@latest add https://aiellie.app/r/avatar.json

03API reference

03
From the Base UI documentation

Displays a user's profile picture, initials, or fallback icon. Renders a <span> element.

Props

PropTypeDefaultDescription
classNamestring | ((state: Avatar.Root.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component's state.
styleReact.CSSProperties | ((state: Avatar.Root.State) => React.CSSProperties | undefined)-Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement | ((props: HTMLProps, state: Avatar.Root.State) => ReactElement)-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.