Migrating from ghl-ui Avatar to HighRise Avatar
This guide will help you migrate from the ghl-ui Avatar component to the new HighRise Avatar component. The Avatar component has been completely redesigned with enhanced accessibility, consistent sizing, improved text handling, and better integration with the HighRise design system.
Component Implementation Changes
Import Changes
diff
- import { UIAvatar } from '@gohighlevel/ghl-ui'
+ import { HLAvatar } from '@platform-ui/highrise'
Basic Usage Changes
Image Avatar
diff
- <UIAvatar
- src="path/to/image.jpg"
- size="medium"
- />
+ <HLAvatar
+ id="user-avatar"
+ src="path/to/image.jpg"
+ @error="handleImageError"
+ />
Rounded Avatar
diff
- <UIAvatar
- src="path/to/image.jpg"
- round
- />
+ <HLAvatar
+ id="user-avatar"
+ src="path/to/image.jpg"
+ round
+ @error="handleImageError"
+ />
Avatar with Slot
diff
- <UIAvatar>JD</UIAvatar>
+ <HLAvatar
+ id="initials-avatar"
+ >JD</HLAvatar>
Avatar with Initials
diff
- <UIAvatar>JD</UIAvatar>
+ <HLAvatar
+ id="initials-avatar"
+ :name="JD"
+ />
Icon Avatar
diff
- <UIAvatar>
- <User01Icon class="w-5 h-5" />
- </UIAvatar>
+ <HLAvatar
+ id="icon-avatar"
+ name="John Smith"
+ >
+ <User01Icon />
+ </HLAvatar>
Props Changes
Removed Props
fallbackSrc
- Usename
prop for initials fallback insteadimgProps
- Use standard HTML attributes on the component directlystyle
- UsepreferredInitialsBgColor
for background color customization- Custom numeric sizes - Use predefined size tokens instead
New Props
Prop Name | Type | Default | Description |
---|---|---|---|
id (required) | string | - | Unique identifier for accessibility |
name (required) | string | - | Full name to generate initials from (e.g., "John Doe" → "JD") |
preferredInitialsBgColor | string | undefined | Custom background color for initials avatar |
Modified Props
Prop Name | Old Values | New Values | Default | Notes |
---|---|---|---|---|
size | 'extra-large', 'large', etc. | '2xl', 'xl', 'lg', 'md', 'sm', 'xs', '2xs', '3xs' | 'xs' | Standardized sizing system |
round | boolean | boolean | true | if there is no round prop, it should set to true |
objectFit | CSS object-fit values | 'fill', 'contain', 'cover', 'none', 'scale-down' | 'fill' | Restricted to specific values |
INFO
if there is no size
prop, it should set to sm
in highrise
.
Events Changes
Old Event | New Event | Arguments | Description |
---|---|---|---|
@error | @error | () => void | Emitted when image fails to load |
@load | - | - | Removed - handle in parent if needed |
@click | @click | () => void | Emitted when avatar is clicked |
Slots Changes
Old Slot | New Slot | Description |
---|---|---|
default | default | Main content slot (for text, icons, or custom content) |
overlay | - | Removed - use parent component for overlay functionality |
Examples
Basic Image Avatar
vue
<template>
<HLAvatar id="image-avatar" src="path/to/image.jpg" size="md" @error="handleImageError" />
</template>
<script setup lang="ts">
const handleImageError = () => {
console.log('Image failed to load')
}
</script>
Initials Avatar with Custom Background
vue
<template>
<HLAvatar id="custom-initials-avatar" name="John Doe" size="lg" preferred-initials-bg-color="var(--color-primary-500)" />
</template>
Square Avatar with Object Fit
vue
<template>
<HLAvatar id="square-image-avatar" name="John Smith" src="path/to/image.jpg" :round="false" size="xl" object-fit="cover" />
</template>
Avatar with Icon
vue
<template>
<HLAvatar id="icon-avatar" name="John Smith" size="sm">
<template #default>
<UserIcon class="w-4 h-4" />
</template>
</HLAvatar>
</template>
Size Variants
vue
<template>
<div class="flex gap-2 items-center">
<HLAvatar
v-for="size in ['2xl', 'xl', 'lg', 'md', 'sm', 'xs', '2xs', '3xs']"
:key="size"
:id="'avatar-' + size"
:size="size"
name="John Doe"
/>
</div>
</template>
Size Mapping
ghl-ui Size | HighRise Size | Dimensions | Use Case |
---|---|---|---|
extra-large | 2xl | 64px | Hero sections, profile pages |
large | xl | 56px | Large profile displays |
medium | lg | 48px | Standard profile views |
small | md | 40px | List items, navigation |
extra-small | sm | 32px | Compact lists |
- | xs | 24px | Dense UIs, default size |
- | 2xs | 20px | Very compact displays |
- | 3xs | 16px | Minimal indicators |
Breaking Changes
Required Props
- The
id
prop is now required for accessibility - The
name
prop is now required for all avatar variants - Both must be unique within the page context
- The
Size System Changes
- Removed support for numeric sizes
- New standardized size tokens
- Default size changed to 'xs' (24px)
Initials Generation
- Now requires
name
prop instead of direct text content - Automatically generates initials from full name
- Example:
name="John Doe"
→ displays "JD"
- Now requires
Styling Changes
- Removed direct style prop support
- Use
preferredInitialsBgColor
for background customization - Uses CSS variables for theming
Default Behavior
round
prop defaults totrue
(wasfalse
)- Removed
fallbackSrc
in favor of initials - Removed overlay slot
Event Handling
- Removed
@load
event - Simplified error handling
- Click event returns no payload
- Removed
DOM Structure
- Modified internal markup for accessibility
- Added ARIA attributes
- Changed class naming convention
Best Practices
- Always provide a unique
id
prop for accessibility - Use semantic size tokens based on context
- Provide
name
prop for automatic initials generation - Handle image loading errors appropriately
- Use CSS variables for theming when possible
- Follow accessibility guidelines
- Keep avatar dimensions consistent
- Use appropriate image formats and sizes
- Test across different viewports
- Document component usage
Additional Notes
- Enhanced accessibility with ARIA attributes
- Improved performance with optimized rendering
- Better TypeScript support
- Consistent theming with design system
- RTL layout support
- Automatic color generation for initials
- Improved error handling
- Better integration with other HighRise components
- Standardized sizing system
- Simplified API surface