vaiperui

components / avatar

Avatar

Round user picture that falls back to initials when there is no image or it fails to load.

How to use

`name` is required: it gives the initials (first and last words) and the accessible label (`role="img"`), while the image is decorative. Pass `src` for a picture; if it is missing or breaks, the initials show.

preview
Avatar.tsx
import { Avatar } from "vaiperui";
<Avatar name="Camila Souza" />
<Avatar name="Yuki Tanaka" src="/avatars/yuki.jpg" size="lg" />
<Avatar name="Ada Lovelace" variantColor="success" />

Sizes

preview
sm
md
lg
sizes.tsx
<Avatar name="Ada Lovelace" size="sm" />
<Avatar name="Ada Lovelace" size="md" />
<Avatar name="Ada Lovelace" size="lg" />

Colors

preview
primary
success
warning
danger
colors.tsx
<Avatar name="Ada Lovelace" variantColor="primary" />
<Avatar name="Ada Lovelace" variantColor="success" />
<Avatar name="Ada Lovelace" variantColor="warning" />
<Avatar name="Ada Lovelace" variantColor="danger" />

Radius

preview
none
sm
md
lg
full
radius.tsx
<Avatar name="Ada Lovelace" radius="none" />
<Avatar name="Ada Lovelace" radius="sm" />
<Avatar name="Ada Lovelace" radius="md" />
<Avatar name="Ada Lovelace" radius="lg" />
<Avatar name="Ada Lovelace" radius="full" />

Custom color

preview
Orange
Violet
custom-color.tsx
<Avatar name="Ada Lovelace" customColor="#ff6600" />
<Avatar name="Ada Lovelace" customColor={{ light: "#a855f7", dark: "#fde047" }} />

Props

PropValuesDefaultDescription
namestringrequiredFull name: initials and accessible label
srcstringnoneImage URL; initials show if missing or broken
sizesm | md | lgmd32, 40 or 56px
radiusnone | sm | md | lg | fullfullCorner rounding
variantColorprimary | success | warning | dangernoneTints the initials fallback (neutral when omitted)
customColorstring | { light, dark }noneAny CSS color (or a pair per theme) for the initials fallback
(native)spannoneEvery native prop of the element, className, ref, etc.