HextaUI

Avatar: Layout

Avatars never shrink in tight rows. A size class like size-20 scales the initials and badge with it, and long initials never overflow.

ALSupercalifragilisticexpialidocious-team-workspace-name
KJKJWWWWWWWW
import {
  Avatar,
  AvatarBadge,
  AvatarFallback,
  AvatarImage,
} from "@/components/ui/avatar"

export function AvatarLayout() {
  return (
    <div className="flex flex-col items-start gap-4">
      <div className="flex w-64 max-w-full items-center gap-2 rounded-lg border p-2 text-sm">
        <Avatar>
          <AvatarImage src="/preview/landscape.svg" alt="" />
          <AvatarFallback>AL</AvatarFallback>
        </Avatar>
        <span className="min-w-0 truncate">
          Supercalifragilisticexpialidocious-team-workspace-name
        </span>
      </div>
      <div className="flex flex-wrap items-center gap-3">
        <Avatar className="size-20">
          <AvatarImage src="/preview/landscape.svg" alt="" />
          <AvatarFallback>KJ</AvatarFallback>
        </Avatar>
        <Avatar className="size-20" shape="square">
          <AvatarFallback>KJ</AvatarFallback>
          <AvatarBadge status="online" />
        </Avatar>
        <Avatar size="sm">
          <AvatarFallback>WWWWWWWW</AvatarFallback>
        </Avatar>
      </div>
    </div>
  )
}

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

pnpm dlx shadcn@latest add https://hextaui.com/r/avatar-layout.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–
PropTypeDefault
statusColors the dot and labels it for assistive tech. Without it the badge uses the primary color.
"online" | "away" | "busy" | "offline"–

Every prop is in the Avatar API reference.

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