v0.0.2
Demos (demo panel, opens in a new tab)

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

Basic usage: view
BLADE

Each section is an zb:accordion.item (name and title); choose the section open at the start with open.

blade
<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>
PropValues
openSection name
nameSection name; must be unique on the page
titleHeader text

Multiple open sections

Multiple open sections: view
BLADE

multiple opens the sections independently of each other; to start several open, give :open an array of names.

blade
<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>
PropValues
multipletrue | false
open'name' | ['name1', 'name2']

Rich content

Rich content: view
BLADE

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.

blade
<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>
PropValues
class (accordion.item)Classes of the content area

Heading and content parts

Heading and content parts: view
BLADE

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.

blade
<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>
PropValues
zb:accordion.headingHeader; attributes are added to the button
zb:accordion.contentContent; attributes are added to the content area

Disabled section

Disabled section: view
BLADE

A section with disabled cannot be opened and its heading looks faded; suited to steps that are not available yet.

blade
<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?

PropTypeDefaultDescription
multiplebooleanfalseSeveral sections can stay open at the same time
open—nullName, 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—nullHeader text; without it, the section is written with the heading and content parts
indicator—chevronMarker in the headers: chevron · plus · none
indicator-position—endPosition of the marker: end · start
heading-levelnumber3The level of the section headings (2–6)
accordion.item: disabledbooleanfalseThe section cannot be opened; its header and trigger are disabled
accordion.content: lazybooleanfalseContent 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

3 examples

Indicator

Indicator: view
BLADE

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:.

blade
<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>
PropValues
indicatorchevron · plus · none
indicator-positionend · start
indicator (slot, accordion.heading)Custom marker

Lazy content

Lazy content: view
BLADE

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.

blade
<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>
PropValues
lazy (accordion.content)Content is rendered on first open

Free-form trigger

Free-form trigger: view
BLADE

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:.

blade
<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>
PropValues
zb:accordion.triggerUnstyled trigger; attributes go to the button

Developer notes

Events, hooks and details
  • 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 name by themselves.
  • If you put a Livewire component with its own lazy option inside lazy content, that component also loads only when the section opens.
  • zb:accordion.trigger has the same aria-expanded and aria-controls links as the heading.
Zubazar UI · ZubazarDesigned for people.