Migrating from ghl-ui Badge to HighRise Badge
This guide will help you migrate from the ghl-ui Badge component to the new HighRise Badge component. The Badge component has been completely redesigned with enhanced accessibility, consistent sizing, improved color system, and better integration with the HighRise design system.
Component Implementation Changes
Import Changes
diff
- import { UIBadge } from '@gohighlevel/ghl-ui'
+ import { HLBadge } from '@platform-ui/highrise'
Basic Usage Changes
Basic Badge
diff
- <UIBadge value="42">
- <template #content>
- <UIAvatar>JD</UIAvatar>
- </template>
- </UIBadge>
+ <HLBadge
+ id="basic-badge"
+ value="42"
+ color="red"
+ size="md"
+ >
+ <HLAvatar name="John Doe" size="md" />
+ </HLBadge>
Dot Badge
diff
- <UIBadge dot>
- <template #content>
- <UIAvatar>JD</UIAvatar>
- </template>
- </UIBadge>
+ <HLBadge
+ id="dot-badge"
+ dot
+ color="red"
+ size="md"
+ >
+ <HLAvatar name="John Doe" size="md" />
+ </HLBadge>
Custom Content Badge
diff
- <UIBadge>
- <template #content>
- <UIAvatar>JD</UIAvatar>
- </template>
- <template #value>
- <ArrowDownIcon class="w-4 h-4" />
- </template>
- </UIBadge>
+ <HLBadge
+ id="custom-badge"
+ size="xs"
+ :offset="[0, 10]"
+ color="blue"
+ >
+ <HLAvatar name="John Doe" size="md" />
+ <template #value>
+ <ArrowDownIcon class="w-3 h-3" />
+ </template>
+ </HLBadge>
Props Changes
Removed Props
content
slot - Use default slot instead- Custom class names - Use CSS variables for styling
- Custom styles - Use design system tokens
New Props
Prop Name | Type | Default | Description |
---|---|---|---|
id (required) | string | - | Unique identifier for accessibility |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Size of the badge |
Modified Props
Prop Name | Old Values | New Values | Default | Notes |
---|---|---|---|---|
color | string | 'gray' | 'blue' | 'green' | 'red' | 'orange' | 'blueGray' | 'blueLight' | 'crayola' | 'indigo' | 'purple' | 'pink' | 'rose' | 'orangeDark' | 'red' | Standardized color system |
type | string | 'default' | 'success' | 'error' | 'warning' | 'info' | 'default' | Restricted to specific values |
offset | Array | [number | string, number | string] | undefined | More flexible offset positioning |
Slots Changes
Old Slot | New Slot | Description |
---|---|---|
content | default | The content that the badge wraps around |
value | value | Custom content for the badge value |
Examples
Basic Badge with Value
vue
<template>
<HLBadge id="basic-badge" :value="400" :max="99" size="md">
<HLAvatar name="John Doe" size="md" />
</HLBadge>
</template>
Color Variants
vue
<template>
<div class="space-x-4">
<HLBadge id="blue-badge" :value="40" color="blue">
<HLAvatar name="John Doe" size="md" />
</HLBadge>
<HLBadge id="green-badge" :value="40" color="green">
<HLAvatar name="John Doe" size="md" />
</HLBadge>
<HLBadge id="red-badge" :value="40" color="red">
<HLAvatar name="John Doe" size="md" />
</HLBadge>
</div>
</template>
Processing Badge with Custom Position
vue
<template>
<HLBadge id="processing-badge" :value="40" processing :offset="[-10, 10]" color="blue">
<HLAvatar name="John Doe" size="md" />
</HLBadge>
</template>
Custom Content with Icon
vue
<template>
<HLBadge id="icon-badge" size="xs" :offset="[0, 10]" color="blue">
<HLAvatar name="John Doe" size="md" />
<template #value>
<ArrowDownIcon class="text-primary-600 w-3 h-3" />
</template>
</HLBadge>
</template>
Size Mapping
ghl-ui Size | HighRise Size | Use Case |
---|---|---|
- | lg | Large indicators, prominent badges |
Default | md | Standard badges |
- | sm | Compact badges |
- | xs | Minimal indicators |
Breaking Changes
Required Props
- The
id
prop is now required for accessibility - Must be unique within the page context
- The
Slot Changes
- Renamed
content
slot todefault
- Simplified slot structure
- Renamed
Color System
- Restricted to predefined color values
- New semantic color tokens
- Removed custom color support
Size System
- New standardized size tokens
- Fixed dimensions for each size
- Removed custom sizing
Styling Changes
- Uses CSS variables for theming
- Removed custom class support
- New design tokens
Type System
- Restricted to specific type values
- New semantic types
- Removed custom types
Offset Behavior
- More flexible offset positioning
- Support for string values
- Changed default positioning
Best Practices
- Always provide unique
id
props - Use semantic colors based on context
- Choose appropriate sizes for context
- Handle offset carefully
- Use processing state for loading
- Consider mobile responsiveness
- Follow accessibility guidelines
- Use appropriate max values
- Keep badge content concise
- Document component usage