Skip to content
Bladewell
Components
Accordion
Alert
Breadcrumbs
Button
Calendar
Chat
Clock
Command palette
Dropdown
Captcha
Checkbox
Colour picker
Date picker
Date range picker
File upload
Filter builder
Image cropper
Number
OTP
Password
Phone
Radio
Repeater
Search
Select
Show if
Slider
Sortable list
Switch
Tags input
Text input
Textarea
Time picker
Verification code
Field
Icon
Kanban
Auth layout
Sidebar layout
Modal
Pagination
Popover
Price roll
Progress
Stepper
Table
Tabs
Toast
Tooltip
Tooltip cursor
Tree
Docs
Installation
Why Bladewell
For AI agents
Guides
Build a Laravel form from your validation rules
Add a date range picker to a Laravel form
Laravel data table with sorting, filters, pagination
Editable table cells in Laravel with Livewire
A Livewire modal that stays open through re-renders
Using Blade components in Livewire 3 and 4
Two-factor authentication screens for Laravel Fortify
Passkey sign-in for Laravel with Fortify
Real-time notification bell with Laravel Reverb
AI agent actions with Approve and Deny in Laravel
Laravel AI chat with Livewire and streaming replies
Livewire multi-step form with validation per step
Toast notifications in Laravel and Livewire
Livewire file upload with progress and drag and drop
Laravel searchable select that loads from the database
Laravel Blade card, avatar and empty state patterns
Add charts and a rich text editor to a Laravel app
Compare
Bladewell vs Flux: a Free Alternative for Laravel
Bladewell vs Mary UI: daisyUI or Plain Blade
Bladewell vs WireUI: With or Without Alpine
Blade UI Kit Alternative for Laravel 12 and 13
Bladewell vs BladewindUI: Laravel Blade Components
Bladewell vs Sheaf UI: With or Without Alpine
Bladewell vs April UI: Package or Copied-in Code

<x-widget.tree>

Tree Blade component for Laravel and Livewire

A tree of nodes that open and close: a file explorer, cards joined by lines, an org chart, or tick boxes where ticking a parent ticks everything under it. Children can load from your app the first time a node opens. Works inside Livewire components, with wire:model for the ticked values.

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

Usage

In scripts

window.tree is available once the tree script has loaded. <x-widget.tree.item id="docs" label="Docs">…</x-widget.tree.item>

JavaScript
tree.open('docs');
tree.close('docs');

// Or the item element, or anything inside it. Opening an item with children-url fetches them first: await it.
await tree.open(document.querySelector('[data-tree-item][aria-expanded="false"]'));

Children endpoint

The URL in children-url answers GET with the node's children as HTML: tree items, inside a tree of the same look (variant), so each renders that look's styles. The script takes the items out and leaves the tree behind. Give a child that has children of its own its own children-url; one with none left off is a leaf. Check the person may see this member, as for any page.

PHP
Route::get('/members/{member}/children', function (Member $member) {
    Gate::authorize('view', $member);

    return view('members.children', ['children' => $member->referrals()->withCount('referrals')->orderBy('joined_at')->get()]);
})->name('members.children');

// resources/views/members/children.blade.php
<x-widget.tree variant="cards">
    @foreach ($children as $child)
        <x-widget.tree.item
            :label="$child->username"
            :meta="'Level '.$child->level"
            :children-url="$child->referrals_count > 0 ? route('members.children', $child) : null"
        >
            <x-slot:details>Joined {{ $child->joined_at->isoFormat('D MMM YYYY') }} · Team of {{ $child->referrals_count }}</x-slot:details>
        </x-widget.tree.item>
    @endforeach
</x-widget.tree>

Livewire

Inside a Livewire component, bind the checkbox look with wire:model (or wire:model.live) to an array property: public array $permissions = []. Ticking updates it, and setting it in PHP ticks the boxes after the render. Which nodes are open stays as the person left it, so :open only sets how a node starts. Children fetched with children-url stay through renders too.

Blade
<div>
    <x-widget.tree label="Permissions" variant="checkbox" wire:model.live="permissions">
        @foreach ($groups as $group)
            <x-widget.tree.item wire:key="group-{{ $group->id }}" :label="$group->name" open>
                @foreach ($group->permissions as $permission)
                    <x-widget.tree.item wire:key="permission-{{ $permission->id }}" :label="$permission->label" :value="$permission->name" />
                @endforeach
            </x-widget.tree.item>
        @endforeach
    </x-widget.tree>

    <button type="button" wire:click="save">Save</button>
</div>

On the server

The tree can't stop a request that skips it. Here's what to check on your server, and what to keep cheap.

Security

Server cost

  • children-url loads a branch only when someone opens it, so the page doesn't send the whole tree. Use withCount() to know which children have their own, rather than loading grandchildren, and cap very wide branches.

    Laravel: Counting related models · Laravel: Eager loading

Examples

List

The default look: compact rows under indent guides, like a file explorer. open starts a node open, meta adds a count at the end of the row, and href makes a node a link. The arrow keys move through it: Right opens, Left closes or goes up a level.

Show code
Blade
<x-widget.tree label="Files" class="max-w-sm">
    <x-widget.tree.item label="Documents" icon="inbox" meta="3" open>
        <x-widget.tree.item label="Invoices" icon="inbox" meta="2">
            <x-widget.tree.item label="March.pdf" icon="file" href="#invoice-march" />
            <x-widget.tree.item label="April.pdf" icon="file" href="#invoice-april" />
        </x-widget.tree.item>
        <x-widget.tree.item label="Lease.pdf" icon="file" href="#lease" />
        <x-widget.tree.item label="Tax return.pdf" icon="file" href="#tax-return" />
    </x-widget.tree.item>
    <x-widget.tree.item label="Photos" icon="image" meta="2">
        <x-widget.tree.item label="Beach.jpg" icon="image" />
        <x-widget.tree.item label="Garden.jpg" icon="image" />
    </x-widget.tree.item>
    <x-widget.tree.item label="Notes.txt" icon="file" />
</x-widget.tree>

Cards

variant="cards": each node a card, joined to its children by lines, like a referral network. The details slot holds the card's figures and meta its level. Deep trees scroll sideways inside themselves rather than widen the page.

  • amelia.chen Joined 12 Jan 2026 · Team of 5 Level 0
    • ben.okafor Joined 3 Feb 2026 · Team of 2 Level 1
      • chloe.martin Joined 19 Mar 2026 · No team yet Level 2
      • daniel.ruiz Joined 2 Apr 2026 · No team yet Level 2
Show code
Blade
<x-widget.tree label="Referral network" variant="cards">
    <x-widget.tree.item label="amelia.chen" meta="Level 0" open>
        <x-slot:details>Joined 12 Jan 2026 · Team of 5</x-slot:details>
        <x-widget.tree.item label="ben.okafor" meta="Level 1" open>
            <x-slot:details>Joined 3 Feb 2026 · Team of 2</x-slot:details>
            <x-widget.tree.item label="chloe.martin" meta="Level 2">
                <x-slot:details>Joined 19 Mar 2026 · No team yet</x-slot:details>
            </x-widget.tree.item>
            <x-widget.tree.item label="daniel.ruiz" meta="Level 2">
                <x-slot:details>Joined 2 Apr 2026 · No team yet</x-slot:details>
            </x-widget.tree.item>
        </x-widget.tree.item>
        <x-widget.tree.item label="erin.walsh" meta="Level 1">
            <x-slot:details>Joined 28 Feb 2026 · Team of 1</x-slot:details>
            <x-widget.tree.item label="farid.haddad" meta="Level 2">
                <x-slot:details>Joined 7 May 2026 · No team yet</x-slot:details>
            </x-widget.tree.item>
        </x-widget.tree.item>
    </x-widget.tree.item>
</x-widget.tree>

Org

variant="org": top-down, each parent centred over its children, like an org chart. On a narrow screen it scrolls sideways inside itself.

  • Maya Patel Chief Executive
    • Leo Grant Engineering
      • Ivy Tran Platform
      • Omar Said Mobile
    • Nora Field Finance
    • Sam Ito Operations
      • Ana Costa Support
Show code
Blade
<x-widget.tree label="Company" variant="org">
    <x-widget.tree.item label="Maya Patel" open>
        <x-slot:details>Chief Executive</x-slot:details>
        <x-widget.tree.item label="Leo Grant" open>
            <x-slot:details>Engineering</x-slot:details>
            <x-widget.tree.item label="Ivy Tran">
                <x-slot:details>Platform</x-slot:details>
            </x-widget.tree.item>
            <x-widget.tree.item label="Omar Said">
                <x-slot:details>Mobile</x-slot:details>
            </x-widget.tree.item>
        </x-widget.tree.item>
        <x-widget.tree.item label="Nora Field">
            <x-slot:details>Finance</x-slot:details>
        </x-widget.tree.item>
        <x-widget.tree.item label="Sam Ito" open>
            <x-slot:details>Operations</x-slot:details>
            <x-widget.tree.item label="Ana Costa">
                <x-slot:details>Support</x-slot:details>
            </x-widget.tree.item>
        </x-widget.tree.item>
    </x-widget.tree.item>
</x-widget.tree>

Checkbox

variant="checkbox": a tick box on every node. Ticking a parent ticks everything under it, and a parent with only some ticked shows a dash. The values of ticked nodes submit as name[] (here permissions[]); a node without a value only groups. value sets what starts ticked; disabled keeps a node as it is. Space ticks, Enter too.

Permissions
  • Posts
    • View
    • Create
    • Edit
    • Delete
  • Users
    • View
    • Invite
  • Settings

Delete is managed by the owner.

Show code
Blade
<x-widget.tree label="Permissions" variant="checkbox" name="permissions" :value="['posts.view', 'posts.create', 'users.view']" info="Delete is managed by the owner." class="max-w-sm">
    <x-widget.tree.item label="Posts" open>
        <x-widget.tree.item label="View" value="posts.view" />
        <x-widget.tree.item label="Create" value="posts.create" />
        <x-widget.tree.item label="Edit" value="posts.edit" />
        <x-widget.tree.item label="Delete" value="posts.delete" disabled />
    </x-widget.tree.item>
    <x-widget.tree.item label="Users" open>
        <x-widget.tree.item label="View" value="users.view" />
        <x-widget.tree.item label="Invite" value="users.invite" />
    </x-widget.tree.item>
    <x-widget.tree.item label="Settings" value="settings" />
</x-widget.tree>

Load on open

children-url: the node's children come from your app the first time it opens, with a spinner meanwhile, so a network of thousands sends only what's looked at. The URL returns them as HTML, in a tree of the same look (see the endpoint under Usage); a node whose URL returns none becomes a leaf, and one that fails offers to try again.

Show code
Blade
<x-widget.tree label="Referral network" variant="cards">
    <x-widget.tree.item label="amelia.chen" meta="Level 0" :children-url="route('members.children', 1)">
        <x-slot:details>Joined 12 Jan 2026 · Team of 3</x-slot:details>
    </x-widget.tree.item>
</x-widget.tree>

Props

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

<x-widget.tree>

Prop Default Description
label null Its name for screen readers. With the checkbox look it's also shown above the tree, as a field's label.
variant 'list' list: rows with indent guides, like a file explorer. cards: each node a card, joined to its children by lines. org: top-down, each parent centred over its children, like an org chart. checkbox: rows with a tick box each; ticking a parent ticks everything under it, and one with only some ticked shows a dash.
name null checkbox: what the ticked values submit as (name[]). Optional with wire:model, which then names it.
id null Defaults to one made from the name (or the wire:model property).
value null checkbox: the ticked values. Old input wins after a failed submit; with wire:model and no value, the bound property.
error null checkbox: an error message of your own; otherwise the validation error for the name, from the session or Livewire.
info null checkbox: a hint under the tree.
bag 'default' checkbox: which error bag to read the error from.

<x-widget.tree.item>

Prop Default Description
label Required The node's text, which also names it for screen readers.
meta null Short text at the end of the row, such as a count or a level. Read out with the label.
icon null An icon before the label, by name, as the icon widget takes it.
href null A URL: the node is a link, followed on click or Enter.
open false Starts open, showing what's under it.
value null checkbox look: what this node submits when ticked. A node without one only groups the ones under it.
disabled false checkbox look: can't be ticked or unticked, and ticking a parent leaves it as it is.
children-url null Where its children come from when it's first opened: a URL in your app that returns tree items as HTML. For trees too big to send at once, like a referral network.

Slots

<x-slot:details>
More about the node under its label, such as a card's figures. Read out as its description.

Accessibility

All 5 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 tree 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 Field, and the theme and base CSS.

resources/views/components/widget/tree/index.blade.php Show
index.blade.php
resources/views/components/widget/tree/item.blade.php Show
item.blade.php
resources/js/widget/tree/index.js Show
index.js
app/View/Widget/ElementIds.php Show
ElementIds.php
app/View/Widget/FormField.php Show
FormField.php