Migrating from ghl-ui Select to HighRise Select
This guide will help you migrate from the ghl-ui Select component to the new HighRise Select component.
Component Implementation Changes
Import Changes
diff
- import { UISelect } from '@gohighlevel/ghl-ui'
+ import { HLSelect } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UISelect
- v-model:value="selectedValue"
- :options="options"
- placeholder="Select an option"
- @update:value="handleChange"
- />
+ <HLSelect
+ v-model:value="selectedValue"
+ :options="options"
+ placeholder="Select an option"
+ @update:value="handleChange"
+ />
Form Integration Changes
diff
- <UIForm :model="formModel">
- <UIFormItem label="Country">
- <UISelect
- v-model:value="formModel.country"
- :options="countryOptions"
- placeholder="Select country"
- @update:value="handleChange"
- />
- </UIFormItem>
- </UIForm>
+ <HLForm :model="formModel" :rules="rules">
+ <HLFormItem
+ label="Country"
+ path="country"
+ required
+ >
+ <HLSelect
+ id="country-select"
+ v-model:value="formModel.country"
+ :options="countryOptions"
+ placeholder="Select country"
+ @update:value="handleChange"
+ />
+ </HLFormItem>
+ </HLForm>
Multiple Selection Changes
diff
- <UISelect
- id="multi-select"
- v-model:value="selectedValues"
- :options="options"
- multiple
- maxTagCount={3}
- >
- <template #tag="{ option }">
- <span>{{ option.label }}</span>
- </template>
- </UISelect>
+ <HLSelect
+ id="multi-select"
+ v-model:value="selectedValues"
+ :options="options"
+ multiple
+ maxTagCount="responsive"
+ :roundedTags="true"
+ />
Search Implementation Changes
diff
- <UISelect
- id="search-select"
- v-model="selectedValue"
- :options="options"
- filterable
- />
+ <HLSelect
+ id="search-select"
+ v-model:value="selectedValue"
+ :options="options"
+ filterable
+ :showSearchIcon="true"
+ />
Props Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
size | 'lg' | 'md' | 'sm' | 'xs' | '2xs' | '3xs' | Extended size options |
showSearchIcon | boolean | Shows search icon in input |
options | SelectOption[] | Array of options to display. Accepts extended options via SelectOption interface |
inline | boolean | Use inline styling |
showInlineCTA | boolean | Show confirm/cancel buttons |
showInlineBottomBorder | boolean | Show bottom border in inline mode |
roundedTags | boolean | Use rounded styling for tags |
showAvatarInTags | boolean | Show avatar in multiple selection |
optionRenderer | (option: SelectOption) => VNodeChild | undefined | Custom function to render options |
optionHeight | number | undefined | Height of each listed option in pixels |
placeholder | string | undefined | Placeholder text when no selection |
showArrow | boolean | undefined | Show/hide dropdown arrow |
showCheckmark | boolean | undefined | Show/hide option checkmark |
to | string | boolean | undefined | Teleport dropdown to specific element/disable teleport. |
Examples
Basic Select
vue
<template>
<HLForm id="basic-select-form" :model="model" :rules="rules">
<HLFormItem label="Country" path="country" required>
<HLSelect v-model:value="model.country" :options="countries" placeholder="Select a country" filterable />
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref } from 'vue'
import { HLForm, HLFormItem, HLSelect } from '@platform-ui/highrise'
const model = ref({
country: null,
})
const countries = [
{ label: 'United States', value: 'US' },
{ label: 'Canada', value: 'CA' },
{ label: 'United Kingdom', value: 'UK' },
{ label: 'Australia', value: 'AU' },
]
const rules = {
country: [
{
required: true,
message: 'Please select a country',
trigger: 'change',
},
],
}
</script>
Multiple Select
vue
<template>
<HLForm id="multiple-select-form" :model="model">
<HLFormItem label="Skills" path="skills">
<HLSelect v-model:value="model.skills" :options="skillOptions" multiple filterable placeholder="Select skills" />
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref } from 'vue'
import { HLForm, HLFormItem, HLSelect } from '@platform-ui/highrise'
const model = ref({
skills: [],
})
const skillOptions = [
{ label: 'JavaScript', value: 'js' },
{ label: 'TypeScript', value: 'ts' },
{ label: 'Vue.js', value: 'vue' },
{ label: 'React', value: 'react' },
{ label: 'Angular', value: 'angular' },
]
</script>
Custom Rendering
The select component provides powerful customization options through renderOption
and tagRenderer
props. These allow you to customize both how options appear in the dropdown menu and how selected values are displayed as tags.
How Custom Rendering Works
Render Option (
renderOption
):- Customizes how the option appear in the dropdown menu
- Can return plain text or complex Vue components
- Has access to the full option object including custom properties
Tag Rendering (
tagRenderer
):- Customizes how selected values appear in the input
- Used only when an option is selected
- Particularly useful with
multiple
selection
Option Properties:
label
: The display text or componentvalue
: The underlying valuetagRenderer
: Optional custom tag renderingrenderOption
: Optional custom label renderingdescription
: Additional text shown below the label- Custom styling properties (backgroundColor, color, etc.)
Option Renderer:
- Customizes how a option appear in the dropdown menu
- Can return plain text or complex Vue components
- It will have parameter
option
js
// Basic option
{
label: "Option 1",
value: "opt1",
description: "Optional description"
}
js
// Group with children
{
type: "group",
label: "Group 1",
key: "group1",
children: [
{ label: "Child 1", value: "child1" },
{ type: "divider" },
{ label: "Child 2", value: "child2" }
]
}
js
// Tag Renderer
{
label: "Option 1",
value: "opt1",
tagRenderer: () => h(HLTag, { color: "blue" }, "Tag Content")
}
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 and placeholders
- Group related options when appropriate
- Use filterable prop for long option lists
- Implement proper error handling
- Consider using tooltips for additional information
- Use clearable prop when appropriate
- Handle disabled states properly
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