Avatar
ProA picture with an initials or icon fallback, badges, 35 Expressive shapes and groups. Not an M3 component (@windmorph/react-pro).
import { Avatar, AvatarGroup } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action | Where |
|---|---|---|
| Tab | Moves focus to an avatar with href or onPress, and on to the next element. A static avatar is skipped. | |
| Enter | Follows the link.With href | With href |
| Enter or Space | Presses the button.With onPress | With onPress |
Screen reader
- Role
- A static avatar is an image (
role="img"), or hidden (aria-hidden) whendecorative. Withhrefit is alink; withonPress, abutton.AvatarGroupis agroup. - Accessible name
alt, followed by the presence word, thebadgeLabeland thestatusRingLabel("Sam, online, verified, new story"), and for a link withtarget="_blank", "opens in a new tab" (labels.newTab). A group is named once by itsaria-label(oraria-labelledby).- States announced
- None beyond the name: presence, the badge and the status ring are read as part of it, not as separate states.
- The photo (
alt=""), the initials or icon, the presence dot, the badge and the status ring are all hidden from assistive tech; the name on the root carries their meaning. - On a
decorativeavatar, and on a static one in anAvatarGroupthat isn't inside your own link or button, nothing announces the status ring: say what it means in the text beside the avatar, or in the group's label. - Initials are drawn as generated content, so a link or button's visible text never differs from its name.
- In
AvatarGroup, static avatars become decorative, so the group is read once (one inside your own link or button names that control instead); linked or pressable avatars keep their own names. A "+N" avatar is decorative, or named bylabels.overflow("3 more") when it is a link or button.
Focus
- Only an avatar with
hreforonPresscan take focus, in the Tab order where it sits in the page. - Keyboard focus shows M3's focus indicator: a 3px
secondaryoutline 2px outside the avatar, round for M3 Expressive shapes, plus a focus state layer, painted over the photo too. Pointer presses show no ring. - On an avatar with a status ring the indicator moves out past the ring. In an
AvatarGroup, the avatar that holds keyboard focus is drawn above the others, so no neighbour, ring or badge covers its indicator.
Touch target
- A linked or pressable avatar always has a touch target of at least 48 × 48px, invisible and outside its layout:
xs,smandmd(24, 32 and 40px), a number below 48 (size={28}) and a size set from CSS (--wm-avatar-size) get one 48px square, and larger avatars are their own target. Sizes and targets are in px, so they hold at larger text sizes. - When two or more avatars in an
AvatarGroupare links or buttons (the "+N" one included), the group stops overlapping and spaces them 48px minus the avatar size apart (at least 4px), so their touch targets never overlap; a size given as a number or from CSS is spaced the same way. Decorative avatars in a group let presses through to a link they overlap.
Motion
A link or button avatar has the core's state layer: hover and focus fade it in, and a press spreads a ripple. Under reduced motion the ripple appears at full size without growing; the static avatar has no animation.
What you need to do
- Give every avatar
alt(usually the person or business name), or mark itdecorativewhen the name is written next to it. The types require one of the two, andaltfor a link or button. - Pass
labelsto translate the presence words,badgeLabelto say what the badge means, andstatusRingLabelto say what a status ring means ("new story", "live"); the types require it withstatusRing. The ring differs from its inactive form in weight as well as colour, but its meaning is in that label only. - Your own link or button around an avatar with a status ring should move its focus indicator out past the ring (
outline-offsetof the ring's reach, 4px or 5px fromlg, plus your own offset); a link or button avatar does it by itself. - Give
AvatarGroupanaria-label(oraria-labelledby) that names everyone it stands for ("Alex, Sam and 3 others"), and alabels.overflowin your language when "+N" is a link or button. - Your own component around an Avatar in a group is fine: the group reaches it through context. Pass
altandhreforonPressto the Avatar inside, or wrap a static Avatar (withalt) in your own link or button: the avatar then names that control, and it takes presses.