Developer Docs
Quick reference guides with props tables, usage examples, and best practices for rapid development
Avatar
User avatar with images, initials, or icons with optional status indicators
Avatar Components
Flexible avatar components for displaying user images, initials, or icons with optional status indicators. Includes three variants: Avatar (single), AvatarGroup (overlapping), and AvatarWithText (with name/subtitle).
Live Example
Simple
Status
Icon
Group
🔧 Avatar Props
| Prop | Type | Default | Description |
|---|---|---|---|
| name | string | undefined | User name - generates initials if no children provided (e.g., "John Doe" → "JD") |
| initials | string | undefined | Custom initials to display (overrides auto-generated from name) |
| status | 'online' | 'away' | 'busy' | 'offline' | undefined | Status indicator dot color |
| statusPosition | string | 'bottom-right' | Position of status dot: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' |
| gradient | boolean | false | Force gradient type (can also use gradient keyword in class string) |
| class | string | '' | Additional CSS classes - size (vwfsize-*), type (solid/subtle/etc), color (vwfcolor-*), shape (rounded-*) |
| onclick | Function | undefined | Click handler - makes avatar interactive with role="button" |
🔧 AvatarGroup Props
| Prop | Type | Default | Description |
|---|---|---|---|
| max | number | 5 | Maximum number of avatars to display before showing "+N" overflow |
| class | string | '' | CSS classes applied to each avatar (e.g., ring-2 ring-white for separation) |
| containerClass | string | '' | CSS classes for the container div |
🔧 AvatarWithText Props
| Prop | Type | Default | Description |
|---|---|---|---|
| name | string | '' | Primary text/name to display |
| subtitle | string | '' | Secondary text/subtitle (e.g., role, status) |
| reverse | boolean | false | Reverse layout (text on left, avatar on right) |
| class | string | '' | CSS classes for avatar sizing (controls both avatar and text size) |
| titleClass | string | '' | CSS classes for the name/title text |
| subtitleClass | string | '' | CSS classes for the subtitle text |
| onclick | Function | undefined | Click handler - adds hover effect when provided |
💻 Basic Usage
// Avatar with auto-generated initials
Avatar({ name: 'John Doe' }) // Shows "JD"
// Avatar with custom initials
Avatar({ name: 'Jane Johnson', initials: 'JS' })
// Avatar with image (passed as child)
Avatar({ name: 'Alex Chen', status: 'online' })
// Avatar with icon
Avatar({ class: 'vwfcolor-sky vwfsize-xl' }, span({ class: 'oj-ux-ico-contact text-2xl' }))
// Avatar with status indicator
Avatar(
{
name: 'Maria Garcia',
status: 'away',
statusPosition: 'top-right',
class: 'vwfsize-3xl'
},
img({ src: 'https://example.com/avatar.jpg', alt: 'User: Maria Garcia' })
)📏 Size Variants
Avatar supports 15 size variants from vwfsize-3xs to vwfsize-8xl. The size scales the avatar container, text, and status indicator proportionally.
// Small sizes
Avatar({ name: 'SM', class: 'vwfsize-sm' })
Avatar({ name: 'MD', class: 'vwfsize-md' }) // Default
// Large sizes
Avatar({ name: 'LG', class: 'vwfsize-lg' })
Avatar({ name: 'XL', class: 'vwfsize-xl' })
Avatar({ name: '2XL', class: 'vwfsize-2xl' })
// Extra large sizes (great for hero sections)
Avatar({ name: '6XL', class: 'vwfsize-6xl' })
Avatar({ name: '8XL', class: 'vwfsize-8xl' })✨ Type Variants
Avatar supports 8 type variants with automatic type detection from class string (same as Button and Badge).
// Solid (default) - full color background
Avatar({ name: 'Solid', class: 'solid vwfcolor-sky' })
// Subtle - 12% opacity background
Avatar({ name: 'Subtle', class: 'subtle vwfcolor-earth' })
// Accent - 24% opacity background
Avatar({ name: 'Accent', class: 'accent vwfcolor-sunrise' })
// Outerline - transparent with colored border
Avatar({ name: 'Outline', class: 'outerline vwfcolor-sunset' })
// Gradient - two-color gradient
Avatar({ name: 'Gradient', class: 'gradient' })
// Secondary - white background
Avatar({ name: 'Secondary', class: 'secondary' })
// Simple - background partial opacity with text 100% opacity of background color
Avatar({ name: 'Simple Indigo', class: 'simple vwfcolor-[rgb(from_var(--color-indigo)_r_g_b_/_50%)]' }
/ Simple - secondary-10 background with text-secondary
Avatar({ name: 'Simple Indigo', class: 'simple vwfcolor-secondary/10' }
)🟢 Status Indicators
Display user presence with status dots positioned automatically using CSS calc() formulas that scale with avatar size.
// Four status states
Avatar({ name: 'Online', status: 'online' }) // Green dot
Avatar({ name: 'Away', status: 'away' }) // Yellow dot
Avatar({ name: 'Busy', status: 'busy' }) // Red dot
Avatar({ name: 'Offline', status: 'offline' }) // Gray dot
// Custom status position
Avatar({
name: 'User',
status: 'online',
statusPosition: 'top-right' // or 'top-left', 'bottom-left', 'bottom-right'
})Online
Away
Busy
offline
💠 Shape Variants
Override the default rounded-full shape with any Tailwind border-radius utility.
// Circle (default)
Avatar({ name: 'Circle', class: 'rounded-full' })
// Highly rounded square
Avatar({ name: 'Square', class: 'rounded-xl' })
// Rounded square
Avatar({ name: 'Sharp', class: 'rounded-md' })
// Sharp square (2px rounding to avoid cutting sharp, 0px easily achieved if needed)
Avatar({ name: 'Box', class: 'rounded-xs' })🖇️ Avatar Group (Overlapping)
Display multiple avatars with negative margin overlap. Automatically shows "+N" for overflow when more than max avatars provided.
// Basic avatar group
AvatarGroup(
{ max: 3, class: 'vwfsize-lg ring-2 ring-white' },
Avatar({ name: 'Alice' }),
Avatar({ name: 'Bob' }),
Avatar({ name: 'Charlie' }),
Avatar({ name: 'Diana' }),
Avatar({ name: 'Eve' })
) // Shows 3 avatars + "+2" overflow
// Larger group with images
AvatarGroup(
{ max: 5, class: 'vwfsize-xl ring-3 ring-white' },
Avatar({ name: 'User 1' }, img({ src: 'avatar1.jpg' })),
Avatar({ name: 'User 2' }, img({ src: 'avatar2.jpg' })),
// ... more avatars
)
// Z-index stacking: first avatar = highest, last = lowest
// Overlap calculation: ml-[calc(var(--vwf-size)*-1+var(--spacing))]Group Example
Small group (max: 3)
Larger group (max: 5)
Avatar With Text
Combine avatar with name and subtitle in a horizontal layout. Perfect for user lists, contact cards, or comment sections.
// Basic usage
AvatarWithText(
{ name: 'John Doe', subtitle: 'Product Designer' },
Avatar({ name: 'John Doe', status: 'online' })
)
// Reversed layout (text on left)
AvatarWithText(
{
name: 'Jane Smith',
subtitle: 'Engineering Manager',
reverse: true
},
Avatar({ name: 'Jane Smith', status: 'away' })
)
// Custom text styling
AvatarWithText(
{
name: 'Alex Chen',
subtitle: 'CEO & Founder',
class: 'vwfsize-2xl',
titleClass: 'text-base font-bold',
subtitleClass: 'text-sm text-smoke'
},
Avatar({ name: 'Alex Chen', status: 'busy' })
)
// Interactive (clickable)
AvatarWithText(
{
name: 'Maria Garcia',
subtitle: 'Marketing Lead',
onclick: () => showProfile('maria')
},
Avatar({ name: 'Maria Garcia', status: 'online' })
)Gradient Avatars
Use gradient type for colorful two-tone avatars. Gradient start color can be customized with gradient-* utilities.
// Default gradient (sunset → plum)
Avatar({ name: 'Default', class: 'gradient vwfsize-2xl' })
// Custom gradient start colors
Avatar({ name: 'Sunrise-Plum', class: 'gradient-sunrise vwfcolor-plum vwfsize-2xl' })
Avatar({ name: 'Sky-Peach', class: 'gradient-sky vwfcolor-peach vwfsize-2xl' })
Avatar({ name: 'Plum-Sunset', class: 'gradient-plum vwfcolor-sunset vwfsize-2xl' })
Avatar({ name: 'Navy-Earth', class: 'gradient-navy vwfcolor-earth vwfsize-2xl' })⚡️ Best Practices
✓ Do This
✓Use consistent sizing within a UI section
- Keep all avatars in a list at the same size (e.g., vwfsize-lg) for visual consistency.
✓Add ring borders for avatar groups
- Use ring-2 ring-white or ring-3 ring-white to create visual separation between overlapping avatars.
✓Always provide meaningful names
- Even when showing images, provide name prop for fallback initials and accessibility.
✓Use status indicators meaningfully
- Only show status when it's actionable or informative (online/offline in chat, availability in scheduling).
✓Ensure images have proper aspect ratio
- Use object-cover class on img elements to prevent distortion: img({ class: "w-full h-full object-cover" })
✗ Avoid This
✗Don't mix shapes inconsistently
- Stick to one shape (rounded-full, rounded-xl) throughout your UI for cohesiveness.
✗Don't use too many avatars in AvatarGroup
- Keep max between 3-7 for readability. Use "+N" overflow for larger groups.
✗Don't use extreme sizes for interactive avatars
- Interactive avatars should be at least vwfsize-md (touch target 44px+) and no larger than vwfsize-4xl.
Explore More Components
Browse other component categories