@hacline/ui/avatarAvatar
Display an image with fallback content while loading or unavailable.
Usage
Provide each avatar with an accessible name. AvatarImage is shown once the image loads, and AvatarFallback appears when no image is available. This example uses a local docs asset that you can replace with your own.
"use client";
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/components/ui/hacline/components/avatar";
/* oxlint-disable jsx-a11y/prefer-tag-over-role -- The wrapper names both the photo and its text fallback. */
export const Example = () => (
<div className="flex flex-wrap items-center gap-4">
<Avatar aria-label="Lake project" className="size-12" role="img">
<AvatarImage alt="" src="/examples/alpine-lake.jpg" />
<AvatarFallback>LK</AvatarFallback>
</Avatar>
<Avatar aria-label="Mountain project" className="size-12" role="img">
<AvatarFallback>MT</AvatarFallback>
</Avatar>
</div>
);Stacked Collaborator Avatars
Place each avatar inside a member list. Even when displaying only initials, accessible names distinguish every collaborator.
- AL
- NZ
- MC
"use client";
import {
Avatar,
AvatarFallback,
} from "@/components/ui/hacline/components/avatar";
const team = [
{ initials: "AL", name: "Alice Lin" },
{ initials: "NZ", name: "Noah Zhou" },
{ initials: "MC", name: "Maya Chen" },
];
/* oxlint-disable jsx-a11y/prefer-tag-over-role -- The initials are a text alternative to a photo. */
export const Example = () => (
<ul aria-label="Project collaborators" className="flex">
{team.map(({ initials, name }) => (
<li className="not-first:-ms-2" key={name}>
<Avatar
aria-label={name}
className="border-hl-bg border-2"
role="img"
title={name}
>
<AvatarFallback>{initials}</AvatarFallback>
</Avatar>
</li>
))}
</ul>
);Parts
| Part | Description |
|---|---|
AvatarFallback | Shown while there's no loaded image, after its delay. |
AvatarImage | A real <img>, hidden until it loads. Every image attribute passes through, like crossOrigin, referrerPolicy, srcSet and sizes. |
Props
Prop
Type
DataTable
Hybrid data table built on TanStack Table v9 and TanStack Virtual v3. Supports zero-boilerplate and composable APIs, sorting, faceted filtering, pagination, row selection, expandable rows, logical column pinning, column resizing, and 10k+ row virtualization.
Carousel
Display a collection of content in a scrollable paginated view.
