Skip to content
Bladewell

<x-widget.accordion>

Accordion Blade component for Laravel and Livewire

Disclosure panels on <details>, as tinted panels, a bordered list or cards. Panels sharing a name open one at a time. The menu variant groups links in a sidebar that scrolls on its own and opens at the current page. Works inside Livewire components: a render updates what's inside and leaves panels open or shut as they were.

php artisan bladewell:add accordion
Also adds
Icon
Used by
Sidebar layout
Works with
Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+

Usage

Remember

remember keeps a menu where it was scrolled from page to page, so the link you click stays under the pointer: the menu is put back before the next page is painted, and the current item is only centred when it would otherwise be out of view. That takes a small inline script, which carries your CSP nonce if you set one with Vite::useCspNonce(); under a CSP that blocks it, the menu still opens with the current item centred. Give each menu its own key ("docs" here), or write just remember to use its label.

Blade
<x-widget.accordion.menu label="Documentation" remember="docs" class="max-h-[calc(100dvh-8rem)]">
    <x-widget.accordion.menu-item href="{{ route('docs.intro') }}" :current="request()->routeIs('docs.intro')">Introduction</x-widget.accordion.menu-item>

    <x-widget.accordion variant="menu" title="Billing">
        <x-widget.accordion.menu-item href="{{ route('docs.refunds') }}" :current="request()->routeIs('docs.refunds')">Refunds</x-widget.accordion.menu-item>
    </x-widget.accordion>
</x-widget.accordion.menu>

Livewire

Inside a Livewire component, a render updates what's in each panel and leaves it open or shut as the person left it, the closing animation and the one-at-a-time group included. So :open only sets how a panel starts; changing it in PHP later doesn't open or close it. In a menu, the group someone opened and the #section link they clicked stay as they were too. Give panels built in a loop a wire:key.

Blade
<div class="flex flex-col gap-2">
    @foreach ($orders as $order)
        <x-widget.accordion wire:key="order-{{ $order->id }}" name="orders" :title="'Order '.$order->number">
            {{ $order->status }}: {{ $order->total }}

            <button type="button" wire:click="refund({{ $order->id }})">Refund</button>
        </x-widget.accordion>
    @endforeach
</div>

Examples

Faq

Panels that share a name close each other, so only one answer is open at a time.

How long does a withdrawal take?
Most withdrawals complete within 30 minutes. Network congestion can add delays.
Which networks are supported?
TRC20, ERC20 and BEP20. Always check the network before sending funds.
Why was my transaction declined?
Common reasons are an incorrect address, insufficient balance or a daily limit.
Show code
Blade
<div class="flex flex-col gap-2">
    <x-widget.accordion name="faq" title="How long does a withdrawal take?" open>
        Most withdrawals complete within 30 minutes. Network congestion can add delays.
    </x-widget.accordion>
    <x-widget.accordion name="faq" title="Which networks are supported?">
        TRC20, ERC20 and BEP20. Always check the network before sending funds.
    </x-widget.accordion>
    <x-widget.accordion name="faq" title="Why was my transaction declined?">
        Common reasons are an incorrect address, insufficient balance or a daily limit.
    </x-widget.accordion>
</div>

Bordered

variant="bordered": a divided list with no panels, the usual shape for an FAQ.

Can I change my plan later?
Yes. Upgrades apply straight away; downgrades take effect at the next billing date.
Do you offer refunds?
Within 14 days of payment, in full, no questions asked.
How do I close my account?
Go to Settings, then Account, then Close account. Your data is deleted after 30 days.
Show code
Blade
<div>
    <x-widget.accordion variant="bordered" name="help" title="Can I change my plan later?">
        Yes. Upgrades apply straight away; downgrades take effect at the next billing date.
    </x-widget.accordion>
    <x-widget.accordion variant="bordered" name="help" title="Do you offer refunds?">
        Within 14 days of payment, in full, no questions asked.
    </x-widget.accordion>
    <x-widget.accordion variant="bordered" name="help" title="How do I close my account?">
        Go to Settings, then Account, then Close account. Your data is deleted after 30 days.
    </x-widget.accordion>
</div>

Cards

variant="card": each item is its own card, which suits settings and grouped forms.

Notifications
Email me when a withdrawal completes, fails, or needs another check.
Security
Two-factor authentication is on. You signed in from 2 devices this month.
Show code
Blade
<div class="flex flex-col gap-3">
    <x-widget.accordion variant="card" title="Notifications" open>
        Email me when a withdrawal completes, fails, or needs another check.
    </x-widget.accordion>
    <x-widget.accordion variant="card" title="Security">
        Two-factor authentication is on. You signed in from 2 devices this month.
    </x-widget.accordion>
</div>

Flush

flush drops the body's padding and text style, so content like this list runs edge to edge.

Fees by network
TRC20
1.00 USDT
ERC20
4.50 USDT
BEP20
0.80 USDT
Show code
Blade
<x-widget.accordion variant="card" title="Fees by network" open flush>
    <dl class="divide-line border-line divide-y border-t text-sm">
        @foreach (['TRC20' => '1.00 USDT', 'ERC20' => '4.50 USDT', 'BEP20' => '0.80 USDT'] as $network => $fee)
            <div class="flex justify-between px-5 py-3">
                <dt class="text-foreground/75">{{ $network }}</dt>
                <dd class="font-medium">{{ $fee }}</dd>
            </div>
        @endforeach
    </dl>
</x-widget.accordion>

Custom header

Pass a header slot instead of a title to put anything in the summary row.

Account limits Verified
Daily withdrawal limit: 50,000 USDT. Monthly: 1,000,000 USDT.
Show code
Blade
<x-widget.accordion>
    <x-slot:header>
        <span class="flex items-center gap-2">
            Account limits
            <span class="bg-primary/10 text-primary rounded-full px-2 py-0.5 text-xs">Verified</span>
        </span>
    </x-slot:header>
    Daily withdrawal limit: 50,000 USDT. Monthly: 1,000,000 USDT.
</x-widget.accordion>

Menu

variant="menu" inside <x-widget.accordion.menu>: a sidebar that scrolls on its own and opens already scrolled to the current page, with no flash of the top of the list first. Groups start open; :open="false" closes one. With #section links like these, the highlight follows the link you click and the URL's #hash.

Show code
Blade
<x-widget.accordion.menu label="Documentation" class="max-h-72 max-w-64">
    <x-widget.accordion.menu-item href="#introduction">Introduction</x-widget.accordion.menu-item>
    <x-widget.accordion.menu-item href="#installation">Installation</x-widget.accordion.menu-item>

    <x-widget.accordion variant="menu" title="Getting started">
        <x-widget.accordion.menu-item href="#first-steps">First steps</x-widget.accordion.menu-item>
        <x-widget.accordion.menu-item href="#configuration">Configuration</x-widget.accordion.menu-item>
        <x-widget.accordion.menu-item href="#directory-structure">Directory structure</x-widget.accordion.menu-item>
    </x-widget.accordion>

    <x-widget.accordion variant="menu" title="Billing">
        <x-widget.accordion.menu-item href="#plans">Plans</x-widget.accordion.menu-item>
        <x-widget.accordion.menu-item href="#invoices">Invoices</x-widget.accordion.menu-item>
        <x-widget.accordion.menu-item href="#refunds" current>Refunds</x-widget.accordion.menu-item>
        <x-widget.accordion.menu-item href="#tax">Tax</x-widget.accordion.menu-item>
    </x-widget.accordion>

    <x-widget.accordion variant="menu" title="Account" :open="false">
        <x-widget.accordion.menu-item href="#profile">Profile</x-widget.accordion.menu-item>
        <x-widget.accordion.menu-item href="#security">Security</x-widget.accordion.menu-item>
    </x-widget.accordion>

    <x-widget.accordion.menu-item href="#changelog">Changelog</x-widget.accordion.menu-item>
</x-widget.accordion.menu>

Props

Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.

<x-widget.accordion>

Prop Default Description
title null The header text, or use the header slot for markup.
open null Starts open. A menu group is open unless set to false, so it paints the same on every page.
name null Items sharing a name open one at a time.
variant 'default' default, bordered, card, or menu (a group of links inside an accordion.menu).
flush false No padding or text style on the body, for content that runs edge to edge.
icon null An icon before the header, by icon name ("shopping-bag"). On a menu group in a collapsed sidebar-layout it's what stays in view; a group without one shows its first letter there instead.

<x-widget.accordion.menu>

Prop Default Description
label Required Names the navigation for screen readers ("Components", "Settings").
remember null Keep where it was scrolled from page to page, under this key ("docs"), or the label's with just `remember`.

<x-widget.accordion.menu-item>

Prop Default Description
href Required Where the link goes: another page, or a #section of this one.
current false The page you're on: highlighted, announced as the current page, and where the menu opens scrolled to. For #section links, resources/js/widget/accordion moves it as they're clicked and as the URL's #hash changes.
icon null An icon before the text, by icon name ("layout-dashboard"). In a collapsed sidebar-layout it's what stays in view; a link without one shows its first letter there instead.

Accessibility

All 6 examples above are checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.

Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.

Source

What bladewell:add accordion writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from the components it also adds , and the theme and base CSS.

resources/views/components/widget/accordion/index.blade.php Show
index.blade.php
resources/views/components/widget/accordion/menu-item.blade.php Show
menu-item.blade.php
resources/views/components/widget/accordion/menu.blade.php Show
menu.blade.php
resources/js/widget/accordion/index.js Show
index.js