Avatar
Shows the image at src (any image URL) if it loads, otherwise initials from name. size: sm, md, lg. shape: circle (default), rounded, square.
KMKMImages, custom content and links. Pass children (an icon or your own <img>) to show it instead of the initials, and href to make the avatar a link to a profile or page. target, rel and onClick go to the link, and linkComponent / linkProp swap in a router link like AppBar. The order is: image, then children, then initials. name is the accessible name, for the link too.
Props
srcstringImage URL; shown if it loads, otherwise children or initials are.
altstringDefault:''Alt text of the image. Leave empty when name already says who it is.
namestringPerson’s name (initials and accessible name, also for the link).
size'sm' | 'md' | 'lg'Default:'md'Size.
shape'circle' | 'rounded' | 'square'Default:'circle'Outline of the avatar.
hrefstringMakes the avatar a link to this URL.
linkComponentElementTypeDefault:'a'Component used for the link, e.g. a router Link.
linkPropstringDefault:'href'Name of the destination prop on linkComponent (e.g. "to" for react-router).
childrenReactNodeCustom content (icon, <img>) shown instead of the initials.
classNamestringDefault:''Extra classes for the root element.
...restAny other props are passed to the underlying element.
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | – | Image URL; shown if it loads, otherwise children or initials are. |
alt | string | '' | Alt text of the image. Leave empty when name already says who it is. |
name | string | – | Person’s name (initials and accessible name, also for the link). |
size | 'sm' | 'md' | 'lg' | 'md' | Size. |
shape | 'circle' | 'rounded' | 'square' | 'circle' | Outline of the avatar. |
href | string | – | Makes the avatar a link to this URL. |
linkComponent | ElementType | 'a' | Component used for the link, e.g. a router Link. |
linkProp | string | 'href' | Name of the destination prop on linkComponent (e.g. "to" for react-router). |
children | ReactNode | – | Custom content (icon, <img>) shown instead of the initials. |
className | string | '' | Extra classes for the root element. |
...rest | – | Any other props are passed to the underlying element. |
