Migrating from ghl-ui RadioGroupItem to HighRise RadioCard
This guide will help you migrate from the ghl-ui RadioGroupItem component to the new HighRise RadioCard component.
Component Implementation Changes
Import Changes
diff
- import { UIRadioGroup, UIRadioGroupItem } from '@gohighlevel/ghl-ui'
+ import { HLRadioGroup, HLRadioCard } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UIRadioGroup
- v-model:value="selectedValue"
- >
- <UIRadioGroupItem
- value="1"
- title="Basic Plan"
- description="Perfect for small businesses"
- icon="star"
- @change="handleChange"
- >
- <template #icon><LayersTwo02Icon class="w-8 h-8" /></template>
- </UIRadioGroupItem>
- <UIRadioGroupItem
- value="2"
- title="Pro Plan"
- description="Ideal for growing businesses"
- icon="star-fill"
- @change="handleChange"
- >
- <template #icon><LayersTwo02Icon class="w-8 h-8" /></template>
- </UIRadioGroupItem>
- </UIRadioGroup>
+ <HLRadioGroup
+ id="plan-group"
+ :value="selectedValue"
+ :radioCardGroup="true"
+ >
+ <HLRadioCard
+ value="1"
+ title="Basic Plan"
+ description="Perfect for small businesses"
+ icon="star"
+ @change="handleChange"
+ >
+ <template #icon><LayersTwo02Icon /></template>
+ </HLRadioCard>
+ <HLRadioCard
+ value="2"
+ title="Pro Plan"
+ description="Ideal for growing businesses"
+ icon="star-fill"
+ @change="handleChange"
+ >
+ <template #icon><LayersTwo02Icon /></template>
+ </HLRadioCard>
+ </HLRadioGroup>
Form Integration Changes
diff
- <UIForm :model="formModel">
- <UIFormItem label="Select Plan">
- <UIRadioGroup
- v-model:value="formModel.plan"
- >
- <UIRadioGroupItem
- value="basic"
- title="Basic Plan"
- description="Perfect for small businesses"
- icon="star"
- >
- <template #icon><LayersTwo02Icon /></template>
- </UIRadioGroupItem>
- <UIRadioGroupItem
- value="pro"
- title="Pro Plan"
- description="Ideal for growing businesses"
- icon="star-fill"
- >
- <template #icon><LayersTwo02Icon /></template>
- </UIRadioGroupItem>
- </UIRadioGroup>
- </UIFormItem>
- </UIForm>
+ <HLForm :model="formModel" :rules="rules">
+ <HLFormItem
+ label="Select Plan"
+ path="plan"
+ required
+ >
+ <HLRadioGroup
+ id="plan-group"
+ v-model:value="formModel.plan"
+ >
+ <HLRadioCard
+ value="basic"
+ title="Basic Plan"
+ description="Perfect for small businesses"
+ icon="star"
+ @change="handleChange"
+ >
+ <template #icon><LayersTwo02Icon /></template>
+ </HLRadioCard>
+ <HLRadioCard
+ value="pro"
+ title="Pro Plan"
+ description="Ideal for growing businesses"
+ icon="star-fill"
+ @change="handleChange"
+ >
+ <template #icon><LayersTwo02Icon /></template>
+ </HLRadioCard>
+ </HLRadioGroup>
+ </HLFormItem>
+ </HLForm>
Props Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
size | size | New size options: 'sm', 'md', 'lg' |
Examples
Basic RadioCard Group
vue
<template>
<HLRadioGroup id="plan-group" v-model:value="selectedValue">
<HLRadioCard value="basic" title="Basic Plan" description="Perfect for small businesses" icon="star" />
<HLRadioCard value="pro" title="Pro Plan" description="Ideal for growing businesses" icon="star-fill" />
</HLRadioGroup>
</template>
<script setup>
import { ref } from 'vue'
import { HLRadioGroup, HLRadioCard } from '@platform-ui/highrise'
const selectedValue = ref('')
</script>
RadioCard with Validation
vue
<template>
<HLForm :model="formModel" :rules="rules">
<HLFormItem label="Select Plan" path="plan" required>
<HLRadioGroup id="plan-group" v-model:value="formModel.plan" :status="validationStatus" :validation-message="validationMessage">
<HLRadioCard value="basic" title="Basic Plan" description="Perfect for small businesses" icon="star" />
<HLRadioCard value="pro" title="Pro Plan" description="Ideal for growing businesses" icon="star-fill" />
</HLRadioGroup>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref, computed } from 'vue'
import { HLForm, HLFormItem, HLRadioGroup, HLRadioCard } from '@platform-ui/highrise'
const formModel = ref({
plan: '',
})
const validationStatus = computed(() => {
if (!formModel.value.plan) return 'error'
return undefined
})
const validationMessage = computed(() => {
if (!formModel.value.plan) return 'Please select a plan'
return undefined
})
const rules = {
plan: [
{
required: true,
message: 'Please select a plan',
trigger: 'change',
},
],
}
</script>
RadioCard with Custom Layout
vue
<template>
<HLForm :model="formModel">
<HLFormItem label="Select Plan" path="plan">
<div class="grid grid-cols-2 gap-4">
<HLRadioGroup id="plan-group" v-model:value="formModel.plan">
<HLRadioCard value="basic" title="Basic Plan" description="Perfect for small businesses" icon="star" />
<HLRadioCard value="pro" title="Pro Plan" description="Ideal for growing businesses" icon="star-fill" />
</HLRadioGroup>
</div>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref } from 'vue'
import { HLForm, HLFormItem, HLRadioGroup, HLRadioCard } from '@platform-ui/highrise'
const formModel = ref({
plan: '',
})
</script>
RadioCard with Disabled Options
vue
<template>
<HLForm :model="formModel">
<HLFormItem label="Select Plan" path="plan">
<HLRadioGroup id="plan-group" v-model:value="formModel.plan">
<HLRadioCard value="basic" title="Basic Plan" description="Perfect for small businesses" icon="star" />
<HLRadioCard value="pro" title="Pro Plan" description="Ideal for growing businesses" icon="star-fill" />
<HLRadioCard value="enterprise" title="Enterprise Plan" description="For large organizations" icon="star-fill" disabled />
</HLRadioGroup>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref } from 'vue'
import { HLForm, HLFormItem, HLRadioGroup, HLRadioCard } from '@platform-ui/highrise'
const formModel = ref({
plan: '',
})
</script>
Best Practices
- Always provide a unique
id
for accessibility - Use
v-model:value
for two-way binding - Implement proper form validation
- Use appropriate size variants
- Consider mobile responsiveness
- Add proper ARIA labels
- Handle loading states appropriately
- Use descriptive titles and descriptions
- Group related options logically
- Use consistent spacing and alignment
- Implement proper error handling
- Consider using tooltips for additional information
- Handle disabled states properly
- Use appropriate layout for different screen sizes
- Choose meaningful icons that represent the options
Additional Notes
- The component automatically handles focus states
- Error states are managed through validation status
- Supports keyboard navigation
- Maintains consistent styling with other form components
- Handles disabled states consistently
- Integrates seamlessly with form validation
- Maintains accessibility standards
- Supports custom styling through CSS variables
- Provides clear visual feedback for all states
- Works well on both desktop and mobile devices
- Supports both controlled and uncontrolled modes
- Includes built-in validation support
- Enhanced visual presentation with icons and descriptions
- Better user experience for complex selection scenarios