Skip to content

Migrating from UICollapse to HighRise Accordion

This guide will help you migrate from the UICollapse component to the new HighRise Accordion component. The component has been renamed to Accordion for better semantic meaning and enhanced with better accessibility, styling options, and consistent behavior.

Component Implementation Changes

Import Changes

diff
- import { UICollapse, UICollapseItem } from '@gohighlevel/ghl-ui'
+ import { HLAccordion, HLAccordionItem } from '@platform-ui/highrise'

Basic Usage Changes

Single Panel Mode (Default)

diff
- <UICollapse v-model="activeNames">
-   <UICollapseItem name="1" title="Section 1">
-     Content 1
-   </UICollapseItem>
-   <UICollapseItem name="2" title="Section 2">
-     Content 2
-   </UICollapseItem>
- </UICollapse>

+ <HLAccordion
+   id="my-accordion"
+   :expanded-names="activeNames"
+   size="md"
+   arrow-placement="right"
+ >
+   <HLAccordionItem
+     id="item-1"
+     name="1"
+     title="Section 1"
+   >
+     Content 1
+   </HLAccordionItem>
+   <HLAccordionItem
+     id="item-2"
+     name="2"
+     title="Section 2"
+   >
+     Content 2
+   </HLAccordionItem>
+ </HLAccordion>

Multiple Panel Mode

diff
- <UICollapse v-model="activeNames" :accordion="false">
-   <UICollapseItem name="1" title="Section 1">
-     Content 1
-   </UICollapseItem>
-   <UICollapseItem name="2" title="Section 2">
-     Content 2
-   </UICollapseItem>
- </UICollapse>

+ <HLAccordion
+   id="multi-accordion"
+   :expanded-names="activeNames"
+   :accordion="false"
+   size="md"
+ >
+   <HLAccordionItem
+     id="item-1"
+     name="1"
+     title="Section 1"
+   >
+     Content 1
+   </HLAccordionItem>
+   <HLAccordionItem
+     id="item-2"
+     name="2"
+     title="Section 2"
+   >
+     Content 2
+   </HLAccordionItem>
+ </HLAccordion>

Props Changes

Accordion (Previously Collapse) Props

ghl-ui PropHighRise PropNotes
-id (required)New required prop for accessibility
v-modelexpanded-namesActive panel names
accordionaccordionSingle panel mode (default: true)
arrow-placementarrow-placementValues: 'left', 'right' (default: 'right')
-sizeValues: 'sm', 'md', 'lg' (default: 'md')
-border-positionValues: 'default', 'item' (default: 'default')
-borderShow border (default: true)
default-active-namesdefault-expanded-namesDefault active panel names
display-directivedisplay-directiveValues: 'if', 'show' (default: 'if')
-zero-paddingRemove padding (default: false)
trigger-areas-Removed - click areas are standardized for better accessibility

AccordionItem (Previously CollapseItem) Props

ghl-ui PropHighRise PropNotes
ghl-ui PropHighRise PropNotes
----------------------------------------------------------------------------------------
-idNew required prop for accessibility
v-modelexpanded-namesActive panel names
accordionaccordionSingle panel mode (default: true)
arrow-placementarrow-placementValues: 'left', 'right' (default: 'right')
-sizeValues: 'sm', 'md', 'lg' (default: 'md')
-border-positionValues: 'default', 'top', 'bottom', 'both'
-borderShow border (default: true)
default-active-namesdefault-expanded-namesDefault active panel names
-display-directiveValues: 'if', 'show' (default: 'if')
-zero-paddingRemove padding (default: false)

AccordionItem (Previously CollapseItem) Props

ghl-ui PropHighRise PropNotes
-idNew required prop for accessibility
titletitlePanel title
namenameUnique identifier
disableddisabledDisable panel (default: false)
-hover-effectShow hover effect (default: true)

Event Changes

ghl-ui EventHighRise EventNotes
update:modelValueitem-header-clickEmitted when panel is clicked

Slot Changes

Accordion Slots

ghl-ui SlotHighRise SlotNotes
defaultdefaultContainer for accordion items

AccordionItem Slots

ghl-ui SlotHighRise SlotNotes
defaultdefaultPanel content
titleheaderCustom header content
-header-extraAdditional header content
-arrowCustom arrow icon

Examples

Basic Accordion

vue
<template>
  <HLAccordion id="basic-accordion" :expanded-names="activeNames" size="md">
    <HLAccordionItem id="item-1" name="1" title="Section 1"> Content 1 </HLAccordionItem>
  </HLAccordion>
</template>

<script setup>
import { ref } from 'vue'

const activeNames = ref(['1'])
</script>

Custom Header

vue
<template>
  <HLAccordion id="custom-header-accordion">
    <HLAccordionItem id="custom-item" name="1">
      <template #header>
        <div class="flex items-center gap-2">
          <IconComponent />
          <span>Custom Header</span>
        </div>
      </template>
      Content
    </HLAccordionItem>
  </HLAccordion>
</template>

With Border Variations

vue
<template>
  <HLAccordion id="bordered-accordion" border-position="both" :border="true">
    <HLAccordionItem id="bordered-item" name="1" title="Section"> Content </HLAccordionItem>
  </HLAccordion>
</template>

Size Mapping

ghl-ui SizeHighRise SizeNotes
-smCompact size
-mdDefault size
-lgLarge size

Best Practices

  1. Always provide unique id props for accessibility
  2. Use semantic panel names
  3. Consider hover effects for better UX
  4. Use appropriate border styles
  5. Choose suitable arrow placement
  6. Implement proper keyboard navigation
  7. Use consistent sizing
  8. Handle content overflow properly
  9. Consider mobile responsiveness
  10. Follow accessibility guidelines

Breaking Changes

  1. Component renamed from Collapse to Accordion
  2. New required id props
  3. Changed event naming
  4. Modified slot structure
  5. New size system
  6. Changed border handling
  7. Modified DOM structure
  8. New theme override system
  9. Changed default values
  10. Modified animation behavior