Displays a user's profile picture, with initials as a fallback.
Installation
Requires the design system foundation (tokens and theme).
Usage
Composition
FLXAvatar stacks its content in a ZStack. Use the following composition to build an avatar:
Put FLXAvatarFallback first so it sits behind FLXAvatarImage, which stays transparent until the image finishes loading. FLXAvatarFallback uppercases its text. FLXAvatarBadge is optional and always pins itself to the bottom-trailing corner.
Sizes
Three sizes, set via size:. Avatars grow with Dynamic Type up to .accessibility2 (about twice their size) and stop there: they're pictures, not text to read, so they don't need to fill the screen at the largest text sizes.
Badge
Overlay a status indicator by adding FLXAvatarBadge alongside the other content. The badge doesn't inherit the avatar's size, so pass a matching size: for .small and .large avatars:
Groups
Wrap a stack of avatars in FLXAvatarGroup to overlap them, and finish the stack with FLXAvatarGroupCount for an overflow indicator:
Custom styling
FLXAvatarStyle is an FLX protocol. Override it for a subtree via .flxAvatarStyle(_:):