AvatarThumbnail
Avatar display component that renders an image, an emoji or a DocyrusIcon on a Tailwind-coloured background with a configurable shape.
Installation
pnpm dlx @docyrus/cli add @docyrus/rn-avatar-thumbnailUsage
import { AvatarThumbnail } from '@/components/docyrus-native/avatar-thumbnail';
<AvatarThumbnail size={48} icon="fal rocket" color="indigo-500" />With Image
<AvatarThumbnail
size={64}
image={{ signed_url: 'https://example.com/avatar.jpg', file_name: 'avatar.jpg' }}
shape="circle"
/>With Emoji
<AvatarThumbnail size={40} icon="๐" color="violet-200" shape="circle" />Shapes
<AvatarThumbnail icon="fal star" color="blue-500" shape="rounded" />
<AvatarThumbnail icon="fal star" color="green-500" shape="circle" />
<AvatarThumbnail icon="fal star" color="red-500" shape="square" />Rendering rules
image.signed_urlpresent โ the image fills the avatar (other props are ignored exceptshape).iconis an emoji โ rendered as text at 62.5% ofsize.iconis any other string ("fal star","huge notification-01", โฆ) โ rendered throughDocyrusIconat 62.5% ofsize.- No icon โ a muted
?.
Icon colour follows the web rule: a Tailwind colour name with level <= 300 (blue-200, amber-300) gets a black icon, any higher level (blue-400, indigo-500) a white one; a hex colour picks black or white by luminance; anything else uses the theme foreground.
Background โ color accepts a Tailwind name ("indigo-500", resolved via resolveColorHex then the theme's full shade palette) or any raw colour. Without color the avatar uses bg-muted.
Size semantics (native vs web)
size is a pixel value on native (default 32). On web it is a Tailwind size step (default 8 โ size-8 = 32px). A value shared between platforms must be multiplied by 4 for native (web size={10} โ native size={40}).
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
size | number | 32 | Width and height in pixels (web: Tailwind step). |
icon | string | null | โ | Emoji, or a DocyrusIcon string such as "fal star". |
color | string | null | โ | Background colour โ Tailwind name ("indigo-500") or raw colour. Falls back to bg-muted. |
image | { signed_url?: string | null; file_name?: string } | null | โ | Image object. When signed_url is present the image is displayed and other fallbacks are skipped. |
shape | 'rounded' | 'circle' | 'square' | 'rounded' | Border radius (rounded-md, rounded-full, rounded-none). |
ref | Ref<View> | โ | Ref to the container View. |
className | string | โ | Additional classes for the container. |
Exports
| Export | Description |
|---|---|
AvatarThumbnail | The avatar component |
avatarThumbnailVariants | tv() definition of the container (shape variant) |
Type Exports
| Type | Description |
|---|---|
AvatarThumbnailProps | Props for the AvatarThumbnail component. |
AvatarThumbnailShape | Shape variant: 'rounded' | 'circle' | 'square'. |