Accordion
Shows sections that open and close when you click their heading; suited to FAQs and long content.
zb:accordion zubazar/ui · free (MIT)
Basic usage
Each section is an zb:accordion.item (name and title); choose the section open at the start with open.
<zb:accordion open="shipping">
<zb:accordion.item name="shipping" title="When does my order ship?">
Orders placed before 15:00 ship the same day; the tracking number is sent by email.
</zb:accordion.item>
<zb:accordion.item name="returns" title="How do I return a product?">
Create a return request from My account > Orders; the return shipping code is valid for 14 days.
</zb:accordion.item>
</zb:accordion>
| Prop | Values |
|---|---|
open | Section name |
name | Section name; must be unique on the page |
title | Header text |
Multiple open sections
multiple opens the sections independently of each other; to start several open, give :open an array of names.
<zb:accordion multiple :open="['personal', 'address']">
<zb:accordion.item name="personal" title="Personal details">
Ayşe Yılmaz · Premium member · joined March 3, 2025
</zb:accordion.item>
<zb:accordion.item name="address" title="Address">
Caferağa Dist., Moda Ave. No. 14, Kadıköy / Istanbul
</zb:accordion.item>
<zb:accordion.item name="history" title="Order history">
Last order September 12, 2026; 9 orders this year.
</zb:accordion.item>
</zb:accordion>
| Prop | Values |
|---|---|
multiple | true | false |
open | 'name' | ['name1', 'name2'] |
Rich content
You can put a list, a button or a form field in a section; a class given to zb:accordion.item is added to the content area.
<zb:accordion open="documents">
<zb:accordion.item name="documents" title="Documents required for a business account">
<ul class="list-disc space-y-1 ps-5">
<li>Tax registration certificate</li>
<li>List of authorized signatories</li>
<li>Trade registry gazette</li>
</ul>
<zb:button size="sm" variant="outline" class="mt-4">Upload document</zb:button>
</zb:accordion.item>
<zb:accordion.item name="duration" title="How long does approval take?">
Business account requests are decided within 2 business days at the latest.
</zb:accordion.item>
</zb:accordion>
| Prop | Values |
|---|---|
class (accordion.item) | Classes of the content area |
Heading and content parts
If the heading needs an icon, a badge or a count, leave out title and write the section with the zb:accordion.heading and zb:accordion.content parts.
<zb:accordion open="pending">
<zb:accordion.item name="pending">
<zb:accordion.heading>
<zb:icon name="clock" size="4" class="text-warning-line" />
Pending tickets
<zb:badge variant="warning">12</zb:badge>
</zb:accordion.heading>
<zb:accordion.content>
12 support tickets are awaiting a reply; the oldest has been waiting for 3 days.
</zb:accordion.content>
</zb:accordion.item>
<zb:accordion.item name="completed">
<zb:accordion.heading>
<zb:icon name="check-circle" size="4" class="text-success-line" />
Resolved tickets
<zb:badge variant="success">48</zb:badge>
</zb:accordion.heading>
<zb:accordion.content>
48 tickets were resolved in September.
</zb:accordion.content>
</zb:accordion.item>
</zb:accordion>
| Prop | Values |
|---|---|
zb:accordion.heading | Header; attributes are added to the button |
zb:accordion.content | Content; attributes are added to the content area |
Disabled section
A section with disabled cannot be opened and its heading looks faded; suited to steps that are not available yet.
<zb:accordion open="packed">
<zb:accordion.item name="packed" title="Orders packed">486 orders were packed and labeled.</zb:accordion.item>
<zb:accordion.item name="shipped" title="Handed to carriers">3 of 4 carriers have picked up their packages.</zb:accordion.item>
<zb:accordion.item name="report" title="End-of-day report (opens at 18:00)" disabled>The report is prepared at the end of the day.</zb:accordion.item>
</zb:accordion>
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
multiple | boolean | false | Several sections can stay open at the same time |
open | — | null | Name, or array of names, of the initially open section(s) |
accordion.item: name | — | — | Required; section name, the id is generated from it |
accordion.item: title | — | null | Header text; without it, the section is written with the heading and content parts |
indicator | — | chevron | Marker in the headers: chevron · plus · none |
indicator-position | — | end | Position of the marker: end · start |
heading-level | number | 3 | The level of the section headings (2–6) |
accordion.item: disabled | boolean | false | The section cannot be opened; its header and trigger are disabled |
accordion.content: lazy | boolean | false | Content is rendered when the section is first opened and stays in place |
accordion.trigger | — | — | Unstyled trigger with a free-form layout, in place of the heading |
Advanced
Indicator
indicator picks the marker in the headers: chevron (default), plus (turns into a minus when open) or none; indicator-position="start" moves it to the left of the text. A heading can use its own icon with <zb:slot:indicator>; style its open state with group-aria-expanded:.
<zb:accordion indicator="plus" indicator-position="start" open="fee">
<zb:accordion.item name="fee" title="Is there a shipping fee?">
Shipping is free on orders of ₺500 or more; smaller orders are charged a ₺49.90 shipping fee.
</zb:accordion.item>
<zb:accordion.item name="hours" title="What are the support hours?">
The support team answers tickets on weekdays between 09:00 and 18:00.
</zb:accordion.item>
</zb:accordion>
<zb:accordion>
<zb:accordion.item name="custom">
<zb:accordion.heading>
Custom indicator
<zb:slot:indicator><zb:icon name="chevron-double-down" size="4" class="transition-transform group-aria-expanded:rotate-180" /></zb:slot:indicator>
</zb:accordion.heading>
<zb:accordion.content>Your own icon; it rotates when the section opens.</zb:accordion.content>
</zb:accordion.item>
</zb:accordion>
| Prop | Values |
|---|---|
indicator | chevron · plus · none |
indicator-position | end · start |
indicator (slot, accordion.heading) | Custom marker |
Lazy content
zb:accordion.content lazy does not render the content until the section is first opened; a chart, a map or a heavy Livewire component does not slow down the page load. Once opened, the content stays in place.
<zb:accordion>
<zb:accordion.item name="stats">
<zb:accordion.heading>
<zb:icon name="chart-bar" size="4" /> Weekly orders chart
</zb:accordion.heading>
<zb:accordion.content lazy>
<zb:chart :height="200" :options="[
'chart' => ['type' => 'bar'],
'series' => [['name' => 'Orders', 'data' => [62, 71, 58, 80, 74, 96, 45]]],
'xaxis' => ['categories' => ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']],
'dataLabels' => ['enabled' => false],
]" />
</zb:accordion.content>
</zb:accordion.item>
</zb:accordion>
| Prop | Values |
|---|---|
lazy (accordion.content) | Content is rendered on first open |
Free-form trigger
zb:accordion.trigger is a heading button without a ready-made look; you build the row's layout yourself. Put links and other buttons next to the trigger, not inside it; style its open state with group-aria-expanded:.
<zb:accordion>
@foreach ([['order-10482', 'Order #10482 · Kadıköy', 'Ahmet Yılmaz', 3], ['order-10483', 'Order #10483 · Üsküdar', 'Elif Kaya', 5]] as [$name, $order, $customer, $items])
<zb:accordion.item :name="$name">
<div class="flex items-center gap-3 px-5 py-3">
<zb:accordion.trigger class="flex min-w-0 flex-1 items-center gap-3 text-left">
<zb:icon name="chevron-right" size="4" class="flex-none text-faint transition-transform group-aria-expanded:rotate-90" />
<zb:avatar :name="$customer" size="sm" />
<span class="min-w-0">
<span class="block truncate text-sm font-medium text-ink">{{ $order }}</span>
<span class="block text-xs text-muted">{{ $customer }} · {{ $items }} items</span>
</span>
</zb:accordion.trigger>
<zb:button size="sm" variant="white">Track shipment</zb:button>
</div>
<zb:accordion.content>
The order was handed to the carrier at 09:00 in the morning; if it cannot be delivered, delivery is retried the next business day.
</zb:accordion.content>
</zb:accordion.item>
@endforeach
</zb:accordion>
| Prop | Values |
|---|---|
zb:accordion.trigger | Unstyled trigger; attributes go to the button |
Developer notes
- By default only one section is open at a time: opening one closes the open one; without
open, all start closed. - The parts find the section's
nameby themselves. - If you put a Livewire component with its own
lazyoption insidelazycontent, that component also loads only when the section opens. zb:accordion.triggerhas the samearia-expandedandaria-controlslinks as the heading.