Skip to content

Avatar

Download .md

An avatar shows a person or an artist as a picture, or as initials when there is no picture.

  • Use it next to names in tables, comments and the account menu.
  • Always pair it with the name in text, unless the name is right next to it.
React
RSBL
Vue
RSBL
123
  1. 1Initials on a soft fill
  2. 2Picture
  3. 3Stack, with a card-colored ring

A circle (radius-full, the only round shape in the system) with an image, or initials on muted with muted-foreground text.

Sizes come from the size-* class; the default is 32px.

React Vue Flutter Type Default Use
AvatarImage src alt AvatarImage :src alt first argument of ShadAvatar string none The picture.
AvatarFallback AvatarFallback placeholder element none Initials while loading or without a picture.
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
const portrait =
"data:image/svg+xml;utf8," +
encodeURIComponent(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#cbd5e1"/><circle cx="32" cy="26" r="12" fill="#94a3b8"/><rect x="14" y="42" width="36" height="22" rx="11" fill="#94a3b8"/></svg>'
)
export default function AvatarDemo() {
return (
<div className="flex items-center gap-3">
<Avatar>
<AvatarImage src={portrait} alt="Foto profil" />
<AvatarFallback>RS</AvatarFallback>
</Avatar>
<Avatar>
<AvatarFallback>BL</AvatarFallback>
</Avatar>
</div>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/avatar.json
  • Give the image an alt that names the person, or alt="" when the name is already next to it.