-
Notifications
You must be signed in to change notification settings - Fork 1
Accordion
Lenny P. edited this page May 17, 2025
·
1 revision
The Accordion component is a collapsible container system for organizing content into expandable sections. It uses Alpine.js for interactivity and supports both manual control and Livewire binding for reactive state management.
<x-accordion>
<x-accordion.item>
<x-accordion.item.trigger>
Section 1
</x-accordion.item.trigger>
<x-accordion.item.content>
Content for section 1.
</x-accordion.item.content>
</x-accordion.item>
<x-accordion.item>
<x-accordion.item.trigger>
Section 2
</x-accordion.item.trigger>
<x-accordion.item.content>
Content for section 2.
</x-accordion.item.content>
</x-accordion.item>
</x-accordion>Renders the wrapper element for the entire accordion.
-
selectedAccordionItem(string|null): Sets the currently opened accordion item's UUID manually or binds to a Livewire model via wire:model for reactive state.
Wraps a single accordion item (trigger + content).
-
uuid(string): Unique identifier for the item. Defaults to a randomly generated UUID. Used to manage open/close state.
Renders the clickable button to toggle an accordion section.
- No specific props, but inherits UUID context from its parent item. Uses ARIA attributes and Tailwind classes for accessibility and style.
Renders the collapsible content area for the associated trigger.
- No specific props. Automatically shown/hidden based on the UUID match with selectedAccordionItem. Uses Alpine.js x-collapse for smooth transitions.
This Accordion component helps you create interactive, accessible collapsible content blocks with Tailwind CSS and Alpine.js. It's ideal for FAQs, toggle panels, and sectioned content displays. It supports both static UUID and Livewire-driven state management.