HextaUI

Avatar: Sizes and shapes

Five sizes, as circles or squares. Initials and the user icon scale with the box, and square corners step down with the size. An empty <AvatarFallback /> shows the user icon.

ALALALALALLTLTLTLTLT
ALALALALALLTLTLTLTLT
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"

const sizes = ["xs", "sm", "default", "lg", "xl"] as const
const shapes = ["circle", "square"] as const

export function AvatarSizes() {
  return (
    <div className="flex flex-col gap-4">
      {shapes.map((shape) => (
        <div key={shape} className="flex flex-wrap items-center gap-3">
          {sizes.map((size) => (
            <Avatar key={`photo-${size}`} size={size} shape={shape}>
              <AvatarImage src="/preview/landscape.svg" alt="" />
              <AvatarFallback>AL</AvatarFallback>
            </Avatar>
          ))}
          {sizes.map((size) => (
            <Avatar key={`initials-${size}`} size={size} shape={shape}>
              <AvatarFallback>LT</AvatarFallback>
            </Avatar>
          ))}
          {sizes.map((size) => (
            <Avatar key={`empty-${size}`} size={size} shape={shape}>
              <AvatarFallback />
            </Avatar>
          ))}
        </div>
      ))}
    </div>
  )
}

This adds the example as components/examples/avatar/sizes.tsx, together with the Avatar component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/avatar-sizes.json

To add only the component, follow the Avatar installation.

Props in this example

The Avatar props this example sets, from the API reference.

PropTypeDefault
sizeInherited from the group when omitted.
"xs" | "sm" | "default" | "lg" | "xl""default"
shapeInherited from the group when omitted.
"circle" | "square""circle"
PropTypeDefault
src
string–
alt
string–

Every prop is in the Avatar API reference.

See them all, with keyboard support and accessibility notes, on the Avatar page.