Wirestrap is still in active development

This project is pre-1.0 and may introduce breaking changes at any time without prior notice.

Table

Table component with auto-truncating column headers: when a header overflows, hovering reveals the full text in a floating tooltip. Pass column definitions via :columns as plain strings or as arrays when you need icons, custom classes, or per-column truncation control. Bulk row selection binds to a Livewire property via bulk, adding a select-all checkbox, per-row checkboxes via x-wirestrap::table.check, and an animated actions bar that slides in when at least one row is selected.

Columns

Pass an array of strings to :columns for simple column headers:

<x-wirestrap::table :columns="['Name', 'Email', 'Role']">
    @foreach ($users as $user)
        <tr wire:key="user-{{ $user->id }}">
            <td>{{ $user->name }}</td>
            <td>{{ $user->email }}</td>
            <td>{{ $user->role }}</td>
        </tr>
    @endforeach
</x-wirestrap::table>

Each column can also be an array. Use icon to add an icon to the header, class to add classes to the label, or any other key to spread it as an HTML attribute:

Icon prop

The icon prop accepts any class string from your preferred icon library, or an array of attributes for full control. Custom icon components are also supported, see icon configuration.

Full Name Email Role
Alice Martin [email protected] Admin
Bob Dupont [email protected] Editor
Claire Bernard [email protected] Viewer
David Rousseau [email protected] Editor
Eva Leroy [email protected] Moderator
François Moreau [email protected] Admin
Grace Chen [email protected] Viewer
Hugo Laurent [email protected] Moderator
Isabelle Simon [email protected] Editor
Jean-Paul Petit [email protected] Viewer
Karen White [email protected] Admin
Luca Ferrari [email protected] Editor
No results found
<x-wirestrap::table
    :columns="[
        ['label' => 'Name', 'icon' => 'bi-person'],
        'Email',
        ['label' => 'Role', 'class' => 'text-end'],
    ]"
>
    ...
</x-wirestrap::table>

Truncation and tooltip

Truncation is on by default. When a header overflows, a tooltip shows the full label on hover. Use 'truncate' => false to opt out on a column. The tooltip key lets you set a custom tooltip text, it will always be visible regardless of overflow:

Note Full name with a deliberately long header that should gets truncated if you don't have a huge screen Role
Internal note Alice Martin Admin
Internal note Bob Dupont Editor
Internal note Claire Bernard Viewer
Internal note David Rousseau Editor
Internal note Eva Leroy Moderator
Internal note François Moreau Admin
Internal note Grace Chen Viewer
Internal note Hugo Laurent Moderator
Internal note Isabelle Simon Editor
Internal note Jean-Paul Petit Viewer
Internal note Karen White Admin
Internal note Luca Ferrari Editor
No results found
$columns = [
    ['label' => 'Note', 'tooltip' => 'Internal note, not visible to the user'], // custom tooltip, always visible
    'Full Name', // truncates; tooltip shows the label on overflow
    ['label' => 'Role', 'truncate' => false], // no truncation, no tooltip
];

Head, foot and caption

When :columns isn't enough, use the head slot to write <thead> manually. foot and caption work the same way:

Users 12
Alice Martin [email protected] Admin
Bob Dupont [email protected] Editor
Claire Bernard [email protected] Viewer
David Rousseau [email protected] Editor
Eva Leroy [email protected] Moderator
François Moreau [email protected] Admin
Grace Chen [email protected] Viewer
Hugo Laurent [email protected] Moderator
Isabelle Simon [email protected] Editor
Jean-Paul Petit [email protected] Viewer
Karen White [email protected] Admin
Luca Ferrari [email protected] Editor
No results found
12 users total
<x-wirestrap::table>
    <x-slot:head> ... </x-slot:head>

    <x-slot:foot> ... </x-slot:foot>

    @foreach ($users as $user)
        <tr wire:key="user-{{ $user->id }}">
            <td>{{ $user->name }}</td>
            <td>{{ $user->email }}</td>
        </tr>
    @endforeach
</x-wirestrap::table>

Animate

Set animate to animate row reorders and additions with FLIP, and apply a fade and height collapse when a row is removed. Each row must have a wire:key so Livewire can track it across morph updates.

Due to CSS restrictions on table element animations, Wirestrap wraps each cell's content in a temporary element when a row is removed. With many columns this may noticeably impact client performance, which is why animate is off by default.

Name Email Role
Alice Martin [email protected] Admin
Bob Dupont [email protected] Editor
Claire Bernard [email protected] Viewer
David Rousseau [email protected] Editor
Eva Leroy [email protected] Moderator
François Moreau [email protected] Admin
Grace Chen [email protected] Viewer
Hugo Laurent [email protected] Moderator
Isabelle Simon [email protected] Editor
Jean-Paul Petit [email protected] Viewer
Karen White [email protected] Admin
Luca Ferrari [email protected] Editor
No results found
<x-wirestrap::table ... animate>
    @foreach ($users as $user)
        <tr wire:key="user-{{ $user->id }}">
            ...
        </tr>
    @endforeach
</x-wirestrap::table>

Bulk selection

Set bulk to the name of a Livewire property. A select-all checkbox with indeterminate state is added to the header automatically. Place x-wirestrap::table.check in each row for the per-row checkbox. Pass an array to :bulk-actions for a built-in actions bar, or use the bulk-actions slot for custom content. Keys other than label, icon, and icon-placement are spread as attributes on the <button>.

Full Name Email Address Role: this label is too long and is truncated
Inactive Alice Martin [email protected] Admin
Active Bob Dupont [email protected] Editor
Inactive Claire Bernard [email protected] Viewer
Active David Rousseau [email protected] Editor
Inactive Eva Leroy [email protected] Moderator
Active François Moreau [email protected] Admin
Inactive Grace Chen [email protected] Viewer
Active Hugo Laurent [email protected] Moderator
Inactive Isabelle Simon [email protected] Editor
Active Jean-Paul Petit [email protected] Viewer
Inactive Karen White [email protected] Admin
Active Luca Ferrari [email protected] Editor
No results found
<x-wirestrap::table bulk="selectedIds" :columns="['Name', 'Email']">
    @foreach ($users as $user)
        <tr wire:key="user-{{ $user->id }}">
            <x-wirestrap::table.check :value="$user->id" />
            <td>{{ $user->name }}</td>
            <td>{{ $user->email }}</td>
        </tr>
    @endforeach
</x-wirestrap::table>
<x-wirestrap::table
    bulk="selectedIds"
    :bulk-actions="[
        ['label' => 'Delete', 'class' => 'btn-danger', 'wire:click' => 'deleteSelected'],
        ['label' => 'Export', 'class' => 'btn-secondary', 'wire:click' => 'export'],
    ]"
    :columns="['Name', 'Email']"
>
    ...
</x-wirestrap::table>
<x-wirestrap::table bulk="selectedIds" :columns="['Name', 'Email']">
    <x-slot:bulk-actions>
        <div class="d-flex gap-2 mb-3">
            <span x-text="$wire.selectedIds.length + ' selected'"></span>
            <button class="btn-danger" wire:click="deleteSelected">Delete</button>
        </div>
    </x-slot:bulk-actions>

    @foreach ($users as $user)
        <tr wire:key="user-{{ $user->id }}">
            <x-wirestrap::table.check :value="$user->id" />
            <td>{{ $user->name }}</td>
            <td>{{ $user->email }}</td>
        </tr>
    @endforeach
</x-wirestrap::table>

Props

Global configuration

Most prop defaults can be overridden globally via config/wirestrap.php.

x-wirestrap::table

Prop Type Default Description
columns array [] Column definitions. Each item is a string (label only) or an array - see Column definition below.
bulk string|null null Livewire property name to bind bulk selection to. Enables the select-all checkbox and table.check.
bulk-actions ComponentSlot|array|null null Bulk actions bar. Array of button definitions or a slot for custom content. Requires bulk.
caption ComponentSlot|string|null null Table caption content.
head ComponentSlot|null null Custom thead content. Used when columns is not set.
foot ComponentSlot|null null tfoot content.
responsive bool config Wraps the table in a responsive container.
animate bool config Animates row additions, reorders, and removals. Requires wire:key on rows.
empty string|null config Message shown when the slot renders no rows. Set to null or empty string to disable.
No results found

Column definition

Prop Type Default Description
label string '' Column header text. Defaults to empty string if omitted.
icon string|array null Icon passed to x-wirestrap::ui.icon.
icon-placement string 'start' Icon position relative to the label: start or end.
class string '' Extra classes on the label.
truncate bool true Truncates the header and shows a tooltip on hover.
tooltip string null Custom tooltip text. When set, the tooltip always shows regardless of truncation.
html string null Raw HTML appended inside th after the label.
... mixed ... Any other key is spread as an HTML attribute on th.
No results found

Bulk actions definition

Prop Type Default Description
label string null Button label.
icon string|array null Icon passed to x-wirestrap::ui.icon.
icon-placement string 'start' Icon position relative to the label: start or end.
... mixed ... Any other key is spread as an HTML attribute on button.
No results found

x-wirestrap::table.check

Prop Type Default Description
class-td string config Classes applied to the wrapping td.
... mixed ... All other attributes are passed through to the checkbox input.
No results found