Basic Usage
Accordion Component
Attributes
Unique identifier for the accordion container. Used to link headers with collapse sections.
Array or Collection of accordion items. Each item should be an associative array with:
title(string): The header textcontent(string): The content text (optional if using slots)show(bool): Whether the item should be expanded by defaultid(string): Custom ID for the accordion item
The CSS framework to use (e.g., ‘bootstrap-5’)
Additional CSS classes to apply to the accordion container
Nested Components
Accordion Item
Individual accordion item with header and collapsible content. Component:x-forms::accordion.item
Attributes:
Unique name/ID for the accordion item collapse section
ID of the parent accordion container
The title text for the header
The content text (displayed if no slot content provided)
Whether the item should be expanded by default
header- Custom header content- Default slot - Custom body content
Accordion Header
The clickable header button that toggles the collapse. Component:x-forms::accordion.header
Attributes:
ID of the collapse element to toggle
The title text to display
Whether the collapse is shown by default
accordion-header with nested accordion-button
Accordion Collapse
The collapsible content section. Component:x-forms::accordion.collapse
Attributes:
ID of the parent accordion container
Text content to display (if no slot content provided)
Whether the collapse is shown by default
accordion-collapse, collapse, show (when expanded)
Using Named Slots
You can use named slots for custom content:- Numeric keys:
item0,item1, etc. - String keys: converted to camelCase (e.g., ‘my_section’ becomes ‘mySection’)
{slotName}Header slots.
Manual Item Definition
Complete Example
Component Structure
Bootstrap Integration
This component uses Bootstrap 5 accordion components:.accordion- Main container.accordion-item- Individual accordion item.accordion-header- Header wrapper.accordion-button- Clickable button.accordion-collapse- Collapsible wrapper.accordion-body- Content area.collapse- Bootstrap collapse utility.show- Class to show the collapse