Avatar

Headless avatar primitives for Roblox UI with delayed fallback rendering.

Stable direction
@lattice-ui/avatar

Part of the stable direction toward v1.0.

What It Is For

Use Avatar for profile chips, player lists, or presence surfaces where image loading and fallback timing need to stay consistent.

The package separates image state from rendering, so you can fully own the Roblox instances used for the picture and the fallback.

Preview size

Live demo is experimental and may contain bugs.

Install

Global CLI command: lattice add avatar

Monorepo local script

Use your package manager wrapper when running the local lattice command.

pnpm lattice add avatar

npm package: @lattice-ui/avatar

Peer dependencies

  • @rbxts/react
  • @rbxts/react-roblox

Public Exports

  • Avatar
  • Avatar.Root
  • Avatar.Image
  • Avatar.Fallback
  • resolveAvatarFallbackVisible

State Model

  • Avatar.Root tracks src, image status, and whether the fallback delay has elapsed.
  • Avatar.Image and Avatar.Fallback read the same state, so they stay synchronized without manual branching in the caller.
  • delayMs controls when the fallback becomes visible while the image is still unresolved.

Key API

Avatar.Root

Pass src and optional delayMs to control image loading behavior and fallback reveal timing.

Avatar.Image

Use asChild to bind the avatar state onto your own ImageLabel or similar host element.

Avatar.Fallback

Render initials, status dots, or silhouette content only when the shared avatar state says the fallback should appear.

Composition Patterns

Player roster rows

Keep the host image primitive small and let the fallback render initials or a status badge without duplicating load/error state outside the avatar tree.

Dense status chips

Short delayMs values work well when a missing image should reveal fallback content quickly in compact, frequently changing lists.

Cautions / Limits

  • Fallback visibility is state-driven; do not mount a separate unconditional fallback outside Avatar.Fallback if you want consistent behavior.
  • A missing or failed image source resolves to fallback immediately, while a loading image waits for the configured delay.