Avatar
An avatar shows a person or an artist as a picture, or as initials when there is no picture.
When to use
Section titled “When to use”- 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.
RSBL
RSBL
Anatomy
Section titled “Anatomy”- 1Initials on a soft fill
- 2Picture
- 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.
Variants
Section titled “Variants”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> )}<script setup lang="ts">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>', )</script>
<template> <div class="flex items-center gap-3"> <Avatar> <AvatarImage :src="portrait" alt="Foto profil" /> <AvatarFallback>RS</AvatarFallback> </Avatar> <Avatar> <AvatarFallback>BL</AvatarFallback> </Avatar> </div></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class AvatarDemo extends StatelessWidget { const AvatarDemo({super.key});
@override Widget build(BuildContext context) { return const Row( mainAxisSize: MainAxisSize.min, children: [ ShadAvatar('assets/portrait.png', placeholder: Text('RS')), SizedBox(width: 12), ShadAvatar('', placeholder: Text('BL')), ], ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/avatar.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/avatar.jsonAccessibility
Section titled “Accessibility”- Give the image an
altthat names the person, oralt=""when the name is already next to it.
