<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.
<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.
<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?
Which networks are supported?
Why was my transaction declined?
Show code Hide code
<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?
Do you offer refunds?
How do I close my account?
Show code Hide code
<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
Security
Show code Hide code
<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 Hide code
<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
Show code Hide code
<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>
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
resources/views/components/widget/accordion/menu-item.blade.php Show
resources/views/components/widget/accordion/menu.blade.php Show
resources/js/widget/accordion/index.js Show