meowerse_
docs menu

Avatar

A rounded square with a person's initial, in three sizes.

import { Avatar } from "@meowerse/ui"; · source packages/ui/src/components/Avatar.tsx

variants and states

small
medium
large

props

proptypedefaultrequired
namestring the person's name; its first character becomes the visible initial and the whole name its accessible name. An empty or blank name shows "?" and is named "no name".—yes
size"sm" | "md" | "lg" the avatar's size."md"no
decorativeboolean true when the name is already visible next to the avatar: it is then hidden from assistive tech, so a screen reader doesn't read the name twice. Leave it false when the avatar stands alone.falseno
classNamestring extra class names to append.—no

css custom properties

variabledarklight
--c-accent#00ff82#0a6e3c
--c-surface#151517#dfded9
--fs-10.75remsame
--fs-20.8125remsame
--fs-41remsame
--r-m4pxsame

Classes: .mw-avatar. Set any of these variables on an ancestor (or wrap a subtree in .mw-theme--dark / .mw-theme--light) to restyle just that part of a page.

usage

small

tsx
import { Avatar } from "@meowerse/ui";

<Avatar name="alxnko" size="sm" />

html (needs @meowerse/ui/tokens.css)
<span role="img" aria-label="alxnko" class="mw-avatar mw-avatar--sm"><span aria-hidden="true" class="mono" data-case="preserve">A</span></span>

medium

tsx
import { Avatar } from "@meowerse/ui";

<Avatar name="Мяу" />

html (needs @meowerse/ui/tokens.css)
<span role="img" aria-label="Мяу" class="mw-avatar mw-avatar--md"><span aria-hidden="true" class="mono" data-case="preserve">М</span></span>

large

tsx
import { Avatar } from "@meowerse/ui";

<Avatar name="Cats & Co" size="lg" />

html (needs @meowerse/ui/tokens.css)
<span role="img" aria-label="Cats &amp; Co" class="mw-avatar mw-avatar--lg"><span aria-hidden="true" class="mono" data-case="preserve">C</span></span>

accessibility

  • An image named by the person's name (role="img" with aria-label, audit U-15); the initial itself is hidden from assistive tech.
  • Where the name is already written next to it, the avatar repeats it; that's harmless, but keep the visible name.

do and don't

do

  • Show the person's name next to the avatar in lists and headers.

don't

  • Don't rely on the initial alone to identify someone.