‮Skip to content‬
uiify

Avatar

‮Named image or fallback initials for a person.‬

‮Browsers‬
Chrome 123+Firefox 121+Safari 17.5+
‮Tier‬
0
‮Bundle compressed‬
293 B
‮Forced layout budget‬
0 ms
‮Axe budget‬
0
‮SSR compatible‬
‮Yes‬
‮Published contract‬
‮Test harness‬

‮Playground‬

Avatar

Ada Lovelace

‮Examples‬

Sizes

The root exposes its size through data-size.

Ada Lovelace
import { Avatar } from "@gunkin/uiify";

export default function Example() {
  return (
    <>
      <Avatar aria-hidden="true" name="Ada Lovelace" fallback="AL" size="sm" />
      <Avatar aria-hidden="true" name="Ada Lovelace" fallback="AL" size="md" />
      <Avatar aria-hidden="true" name="Ada Lovelace" fallback="AL" size="lg" />
      <span>Ada Lovelace</span>
    </>
  );
}

‮API‬

Avatar

‮Prop‬‮Type‬‮Default‬‮Description‬
name*string—‮Accessible name for the person represented by the avatar.‬
fallback*string—‮Text shown when src is omitted; provide meaningful initials or a short name.‬
srcstring—‮Image URL; the image is rendered only when supplied.‬
size"sm" | "md" | "lg"—‮Visual scale written to data-size; omitted when unset.‬
aria-hidden"true"—‮Hide the avatar from assistive technology when adjacent visible text already names the person.‬
classNamestring—‮Class applied to the root element.‬
styleCSSProperties—‮Native root styles.‬
refRef<HTMLElement>—‮Ref forwarded to the rendered root element.‬
renderReactElement | ((props, state) => ReactElement)—‮Replace the rendered element while keeping behavior and accessibility wiring.‬

‮Keyboard‬

‮Key‬‮Action‬

‮Accessibility‬

‮The root is named as an image and the fallback is hidden from assistive technology. Keep a visible name beside decorative avatars and set aria-hidden when that text already names the person. A supplied src renders an image; image-load failures do not trigger a replacement fallback.‬

‮Styling hooks‬

data-uiify-avatardata-partdata-size