Avatar
An easily stylable avatar component.
View as MarkdownAnatomy
Import the component and assemble its parts:
API reference
Root
Displays a user’s profile picture, initials, or fallback icon.
Renders a <span> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Avatar.Root.StateHide
Image
The image to be displayed in the avatar.
Renders an <img> element.
onLoadingStatusChangefunction—
- Description
Callback fired when the loading status changes.
- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-starting-style
Present when the image is animating in.
data-ending-style
Present when the image is animating out.
| Attribute | Description | |
|---|---|---|
data-starting-style | Present when the image is animating in. | |
data-ending-style | Present when the image is animating out. | |
Avatar.Image.StateHide
Fallback
Rendered when the image fails to load or when no image is provided.
Renders a <span> element.
delaynumber—
- Name
- Description
How long to wait before showing the fallback. Specified in milliseconds.
- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type