Avatar
A circular image with a text fallback. Wraps @base-ui/react/avatar: Base UI owns the image load/error state machine that decides when the fallback shows, and we own the surface.
Preview
Rendered from the story the storybook (a11y) CI gate runs axe against — the preview can't show something that hasn't been verified.
Install
Two equivalent paths — the URL works in any shadcn-CLI setup; the alias works once you've registered @interlace in your components.json.
npx shadcn@latest add https://ds.interlace.tools/r/avatar.jsonnpx shadcn@latest add @interlace/avatarHistory
This component is at v1.2.0, first shipped in @interlace/ui 1.0.0. The version is stamped as a banner into the file the install writes, so the copy in your tree says which one you have — compare it with the number above before deciding whether to re-run the install.
@interlace/ui 1.0.01 entry
- Addedminor
The component floor reaches every tier: form, overlay, navigation and display primitives were modelled to the portable 26-rule floor with skeletons, locked breakpoints, and AA contrast measured per composite rather than eyeballed.
Components- @interlace/input
- @interlace/textarea
- @interlace/select
- @interlace/checkbox
- @interlace/radio-group
- @interlace/switch
- @interlace/slider
- @interlace/number-field
- @interlace/form
- @interlace/label
- @interlace/dialog
- @interlace/alert-dialog
- @interlace/sheet
- @interlace/popover
- @interlace/tooltip
- @interlace/hover-card
- @interlace/dropdown-menu
- @interlace/context-menu
- @interlace/tabs
- @interlace/accordion
- @interlace/collapsible
- @interlace/breadcrumb
- @interlace/pagination
- @interlace/toast
- @interlace/card
- @interlace/badge
- @interlace/alert
- @interlace/separator
- @interlace/progress
- @interlace/skeleton
Import
3 named exports — pull the parts you need.
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';Anatomy
Extracted from the primitive's JSDoc header. The source is the only documentation that can't drift.
Avatar (Avatar.Root — size-8, rounded-full, overflow-hidden)
├─ AvatarImage (Avatar.Image — aspect-square size-full)
└─ AvatarFallback (Avatar.Fallback — bg-muted, centred initials)
`size-8` is a default, not a constraint: it is merged through `cn`, so
`className="size-12"` wins. The `loading` skeleton is given the same
`size-8` and the same `className`, so an overridden size survives the swap.API reference
Parsed from the type declarations in the source — the same file the install writes into your tree, so this table can't drift from the component you get.
AvatarProps
Also accepts every prop of Base UI's <Avatar.Root> — behaviour we compose rather than reimplement.
| Prop | Type | Description |
|---|---|---|
| loading | boolean | When true, render a `<Skeleton variant="avatar" />` in place of the normal Avatar surface. Idiomatic state-contract entry — the loading silhouette is shape-matched (size-8 rounded-full — the same size the Root renders) so the layout doesn't shift when the real image lands. |
Skeleton
Pass loading and the component renders a shape-matched <Skeleton /> in its own place — same box, so nothing reflows when the data lands. Below is the same story with loading={true}.
<Avatar loading={isPending} />Accessibility
Every story for this component is rendered headlessly and checked with axe-core (wcag2aa, wcag22aa, best-practice, ACT) on every PR. That gate has no continue-on-error, so what ships has zero known violations.
What follows is what static analysis can see. Axe cannot press a key and never sees an overlay open, so the operable-without-a-mouse claim lives in Behavior instead, where the keyboard path is replayed step by step.
- Focus + keyboard behaviour
- Owned by @base-ui/react/avatar — focus trapping, dismissal and typeahead come from the headless primitive, not from us.
- Focus ring (WCAG 2.2 SC 2.4.13)
- Not focusable — no focus indicator required.
- Reduced motion
- No animation to gate.
- ARIA in the source
- None — semantics come from the element or the Base UI primitive rather than hand-written ARIA.
Examples
2 more states from the same story file.
R-rule compliance
Every primitive in @interlace/ui models to the portable 26-rule floor enforced by the componentApi ESLint preset. The cells below pin exactly where each rule applies in this file.
| Rule | Concept | Where |
|---|---|---|
| R4 | Extends Base UI part props | `React.ComponentProps<typeof BaseAvatar.Root/Image/Fallback>` |
| R6 | data-slot per part | avatar / avatar-image / avatar-fallback |
| R7 | cn + ...rest | `cn('… size-8 …', className)` + `{...props}` |
| R12 | Reuse over wrap | Base UI owns the image load/error machine |
| R19 | Tokens only | `bg-muted` on the fallback face |
| R25 | Client component | Required — Base UI Avatar ships client hooks |
Dependencies
- Base UI primitive
- @base-ui/react/avatar
- Lucide icons
- none
- NPM dependencies
@base-ui/react
- Registry dependencies
Source
The full implementation — components/ui/avatar.tsx once installed.
'use client';
import * as React from 'react';
// @interlace/avatar v1.2.0 — Interlace design system.
// Docs, props and live preview: https://ds.interlace.tools/c/avatar
// What changed since: https://ds.interlace.tools/c/avatar#history
// Generated banner — keep it, the upgrade diff reads this version.
// Mirrors the shadcn Avatar canon, built on Base UI primitives.
// Upstream: https://base-ui.com/react/components/avatar
/**
* @interlace/ui — Avatar
*
* A circular image with a text fallback. Wraps @base-ui/react/avatar: Base UI
* owns the image load/error state machine that decides when the fallback
* shows, and we own the surface.
*
* Ours is the `size-8` clipped circle, the muted fallback face, and a
…101 more lines…Registry JSON
The raw registry record — what the shadcn CLI fetches.