Expandable
A group of collapsible items with shared styling and customizable content.
Install
Run the following command to install the expandable component:
npx acc-nuxt add ExpandableBasic
Pass an items array to render a group. Each item contains trigger text and content.
Group and Item Slots
Pass items to render a group with one border and dividers. Multiple answers can be open together; v-model is an array of booleans in item order.
Each item renders its trigger and content text by default. A numbered trigger or content slot replaces that text for the corresponding item. For example, trigger-1 and content-1 replace the first item's trigger and answer. Slots receive item, index (zero-based), and isExpanded.
The wrapper provides default group styling. The documented CSS variables are available for optional customization.
For one expandable, pass an array with one item. Use trigger-1 and content-1 to supply its markup through slots.
Default Open
Without Icon
Disable Trigger
As div
Persistent State (via useCookie)
Store the boolean array in a cookie to remember the group state across page reloads.
Expand/Collapse All
Set every entry in the group model to true to expand all answers, or false to collapse them all.
Custom Icon Example
Use icon-1 to replace only the first item's icon. Other items keep the default chevron. The slot receives isExpanded for state-dependent icons.
To use the same custom icon for every item, generate a numbered icon slot for each entry with v-for. Each slot uses its own isExpanded state to rotate the icon.
Props
Bindings
Emits
Slots
The expandable component provides the following slots for customization.
CSS Variables
The expandable component can be customized using the following CSS variables.