Migrating from ghl-ui RadioGroup to HighRise RadioGroup
This guide will help you migrate from the ghl-ui RadioGroup component to the new HighRise RadioGroup component.
Component Implementation Changes
Import Changes
diff
- import { UIRadioGroup, UIRadio } from '@gohighlevel/ghl-ui'
+ import { HLRadioGroup, HLRadio } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UIRadioGroup
- v-model="selectedValue"
- >
- <UIRadio value="1">Option 1</UIRadio>
- <UIRadio value="2">Option 2</UIRadio>
- <UIRadio value="3">Option 3</UIRadio>
- </UIRadioGroup>
+ <HLRadioGroup
+ id="radio-group"
+ v-model:value="selectedValue"
+ >
+ <HLRadio value="1">Option 1</HLRadio>
+ <HLRadio value="2">Option 2</HLRadio>
+ <HLRadio value="3">Option 3</HLRadio>
+ </HLRadioGroup>
Form Integration Changes
diff
- <UIForm :model="formModel">
- <UIFormItem label="Gender">
- <UIRadioGroup
- v-model="formModel.gender"
- >
- <UIRadio value="male">Male</UIRadio>
- <UIRadio value="female">Female</UIRadio>
- <UIRadio value="other">Other</UIRadio>
- </UIRadioGroup>
- </UIFormItem>
- </UIForm>
+ <HLForm :model="formModel" :rules="rules">
+ <HLFormItem
+ label="Gender"
+ path="gender"
+ required
+ >
+ <HLRadioGroup
+ id="gender-group"
+ v-model:value="formModel.gender"
+ >
+ <HLRadio value="male">Male</HLRadio>
+ <HLRadio value="female">Female</HLRadio>
+ <HLRadio value="other">Other</HLRadio>
+ </HLRadioGroup>
+ </HLFormItem>
+ </HLForm>
Props Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
v-model | v-model:value | Changed to use value prop |
size | size | New size options: 'sm', 'md', 'lg' |
Examples
Basic RadioGroup
vue
<template>
<HLRadioGroup id="basic-group" v-model:value="selectedValue">
<HLRadio value="1">Option 1</HLRadio>
<HLRadio value="2">Option 2</HLRadio>
<HLRadio value="3">Option 3</HLRadio>
</HLRadioGroup>
</template>
<script setup>
import { ref } from 'vue'
import { HLRadioGroup, HLRadio } from '@platform-ui/highrise'
const selectedValue = ref('')
</script>
RadioGroup with Validation
vue
<template>
<HLForm :model="formModel" :rules="rules">
<HLFormItem label="Gender" path="gender" required>
<HLRadioGroup id="gender-group" v-model:value="formModel.gender" :status="validationStatus" :validation-message="validationMessage">
<HLRadio value="male">Male</HLRadio>
<HLRadio value="female">Female</HLRadio>
<HLRadio value="other">Other</HLRadio>
</HLRadioGroup>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref, computed } from 'vue'
import { HLForm, HLFormItem, HLRadioGroup, HLRadio } from '@platform-ui/highrise'
const formModel = ref({
gender: '',
})
const validationStatus = computed(() => {
if (!formModel.value.gender) return 'error'
return undefined
})
const validationMessage = computed(() => {
if (!formModel.value.gender) return 'Please select a gender'
return undefined
})
const rules = {
gender: [
{
required: true,
message: 'Please select a gender',
trigger: 'change',
},
],
}
</script>
RadioGroup with Custom Layout
vue
<template>
<HLForm :model="formModel">
<HLFormItem label="Payment Method" path="paymentMethod">
<div class="grid grid-cols-2 gap-4">
<HLRadioGroup id="payment-group" v-model:value="formModel.paymentMethod">
<HLRadio value="credit">Credit Card</HLRadio>
<HLRadio value="debit">Debit Card</HLRadio>
<HLRadio value="paypal">PayPal</HLRadio>
<HLRadio value="bank">Bank Transfer</HLRadio>
</HLRadioGroup>
</div>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref } from 'vue'
import { HLForm, HLFormItem, HLRadioGroup, HLRadio } from '@platform-ui/highrise'
const formModel = ref({
paymentMethod: '',
})
</script>
RadioGroup with Disabled Options
vue
<template>
<HLForm :model="formModel">
<HLFormItem label="Subscription" path="subscription">
<HLRadioGroup id="subscription-group" v-model:value="formModel.subscription">
<HLRadio value="free">Free Plan</HLRadio>
<HLRadio value="basic">Basic Plan</HLRadio>
<HLRadio value="premium" disabled>Premium Plan (Coming Soon)</HLRadio>
</HLRadioGroup>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref } from 'vue'
import { HLForm, HLFormItem, HLRadioGroup, HLRadio } from '@platform-ui/highrise'
const formModel = ref({
subscription: '',
})
</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 labels
- 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
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