Table
A card-style, horizontally scrolling container and ready-made table styles for data tables.
zb:table · zb:sortable-th zubazar/ui · free (MIT)
Basic usage
Put your own table tag inside zb:table and give it the ui-table class; columns that do not fit scroll sideways.
<zb:table>
<table class="ui-table">
<thead><tr><th>Customer</th><th>City</th><th>Last order</th></tr></thead>
<tbody>
<tr><td>Ayşe Yılmaz</td><td>Istanbul</td><td>Sep 12, 2026</td></tr>
<tr><td>Mehmet Kaya</td><td>Ankara</td><td>Sep 10, 2026</td></tr>
<tr><td>Zeynep Arslan</td><td>Izmir</td><td>Sep 8, 2026</td></tr>
</tbody>
</table>
</zb:table>
| Prop | Values |
|---|---|
ui-table | Class given to the table tag |
Numbers and alignment
Right-align number columns with text-right and tabular-nums so the digits line up.
<zb:table>
<table class="ui-table">
<thead>
<tr><th>Product</th><th class="text-center">Code</th><th class="text-right">Sales</th><th class="text-right">Satisfaction</th></tr>
</thead>
<tbody>
<tr><td>Wireless headphones</td><td class="text-center">WH-01</td><td class="text-right tabular-nums">312</td><td class="text-right tabular-nums">91.4%</td></tr>
<tr><td>Mechanical keyboard</td><td class="text-center">MK-04</td><td class="text-right tabular-nums">148</td><td class="text-right tabular-nums">75.7%</td></tr>
<tr><td>USB-C charger</td><td class="text-center">UC-02</td><td class="text-right tabular-nums">96</td><td class="text-right tabular-nums">68.8%</td></tr>
</tbody>
</table>
</zb:table>
| Prop | Values |
|---|---|
text-right · text-center | Cell alignment |
tabular-nums | Equal-width digits |
Sortable headers
Write zb:sortable-th instead of th; a click calls your component's sortBy(field) method, and sort-field and sort-direction show the current sort.
<zb:table>
<table class="ui-table">
<thead>
<tr>
<zb:sortable-th field="name" sort-field="sales" sort-direction="desc">Product</zb:sortable-th>
<zb:sortable-th field="sales" sort-field="sales" sort-direction="desc" class="text-right">Sales</zb:sortable-th>
</tr>
</thead>
<tbody>
<tr><td>Wireless headphones</td><td class="text-right tabular-nums">312</td></tr>
<tr><td>Mechanical keyboard</td><td class="text-right tabular-nums">148</td></tr>
</tbody>
</table>
</zb:table>
| Prop | Values |
|---|---|
field | Field name of this column |
sort-field | Current sort field ($sortField) |
sort-direction | asc | desc ($sortDirection) |
Status and actions
Show the status with zb:badge and the row actions with icon buttons that have an aria-label.
<zb:table>
<table class="ui-table">
<thead>
<tr><th>Product</th><th>Note</th><th>Status</th><th class="w-24"><span class="sr-only">Actions</span></th></tr>
</thead>
<tbody>
<tr>
<td class="font-medium text-ink">Mechanical keyboard</td>
<td class="min-w-64 whitespace-normal">The supplier raises prices in November; the campaign price must stay valid until the end of October.</td>
<td><zb:badge variant="success">Active</zb:badge></td>
<td class="text-right">
<zb:button variant="ghost" size="icon" aria-label="Edit"><zb:icon name="pencil-square" /></zb:button>
<zb:button variant="ghost" size="icon" aria-label="Delete" class="text-danger-ink"><zb:icon name="trash" /></zb:button>
</td>
</tr>
</tbody>
</table>
</zb:table>
Empty table
When there are no records, keep the header row and put an zb:empty-state in a single cell; colspan must equal the number of columns.
<zb:table>
<table class="ui-table">
<thead>
<tr><th>Customer</th><th>City</th><th>Last order</th></tr>
</thead>
<tbody>
<tr>
<td colspan="3" class="whitespace-normal">
<zb:empty-state title="No records found" description="Try changing your search or filter criteria." class="border-0" />
</td>
</tr>
</tbody>
</table>
</zb:table>
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
zb:table | — | — | Attributes such as class are added to the scrollable container |
zb:table: sort-method | — | sortBy | The Livewire method a sortable column calls in the composable usage |
zb:table: sort-field · sort-direction | — | null | In composable usage, the shared sort state of the sortable columns |
zb:table: stack | boolean | false | true · sm · md: every row is a card when the table's box is narrower than 640 / 768 pixels |
table.cell: label | — | null | The cell's label on the cards (data-label) |
table.column: align | — | start | start · center · end |
table.column: sortable · field | — | false · null | Sortable header; field is required, sortBy(field) is called on click |
table.cell: align | — | start | start · center · end |
ui-table (class) | — | — | On the table tag: header, cell, row hover and tfoot styles |
sortable-th: field | — | — | Required. sortBy(field) is called on click |
sortable-th: sort-field | — | — | Required. The current sort field |
sortable-th: sort-direction | — | — | Required. asc · desc |
Slots: zb:table: the default slot takes a table tag or the parts (zb:table.columns › zb:table.column, zb:table.rows › zb:table.row › zb:table.cell) · zb:sortable-th: header text.
Advanced
Totals row
A row inside tfoot appears as a totals row, with bold text, a dark top border and a gray background.
<zb:table>
<table class="ui-table">
<thead>
<tr><th>Month</th><th class="text-right">Orders</th><th class="text-right">Returns</th></tr>
</thead>
<tbody>
<tr><td>September 2026</td><td class="text-right tabular-nums">1,248</td><td class="text-right tabular-nums">86</td></tr>
<tr><td>August 2026</td><td class="text-right tabular-nums">1,192</td><td class="text-right tabular-nums">104</td></tr>
</tbody>
<tfoot>
<tr><td>Total</td><td class="text-right tabular-nums">2,440</td><td class="text-right tabular-nums">190</td></tr>
</tfoot>
</table>
</zb:table>
| Prop | Values |
|---|---|
tfoot | Totals row style |
Cards on phones
With stack, every row becomes a card when the table's box is narrower than 640 pixels (stack="md": 768); a cell with data-label becomes a "Label ……… value" line. It looks at the table's box, not the screen, so this narrow example shows cards on a desktop too.
<zb:table stack>
<table class="ui-table">
<thead>
<tr><th>Order</th><th>Customer</th><th>Delivery</th><th>Status</th><th class="text-end">Amount</th></tr>
</thead>
<tbody>
<tr>
<td class="font-medium text-ink">SP-1042</td>
<td>Jane Cooper</td>
<td data-label="Delivery">Courier · Leeds</td>
<td><zb:badge variant="success">Paid</zb:badge></td>
<td class="text-end tabular-nums">$279.90</td>
</tr>
<tr>
<td class="font-medium text-ink">SP-1041</td>
<td>Tom Baker</td>
<td data-label="Delivery">In store</td>
<td><zb:badge variant="warning">Pending</zb:badge></td>
<td class="text-end tabular-nums">$45.99</td>
</tr>
</tbody>
</table>
</zb:table>
| Prop | Values |
|---|---|
stack | true · sm · md |
data-label | The cell's label on the card |
Composable table
Build the table from the zb:table.columns › zb:table.column and zb:table.rows › zb:table.row › zb:table.cell parts; the component draws the table tag. align (start · center · end) aligns the column and the cell.
<zb:table>
<zb:table.columns>
<zb:table.column>Project</zb:table.column>
<zb:table.column>Owner</zb:table.column>
<zb:table.column align="center">Status</zb:table.column>
<zb:table.column align="end">Tasks</zb:table.column>
<zb:table.column align="end">Progress</zb:table.column>
</zb:table.columns>
<zb:table.rows>
<zb:table.row>
<zb:table.cell class="font-medium text-ink">Mobile app</zb:table.cell>
<zb:table.cell>Ahmet Yılmaz</zb:table.cell>
<zb:table.cell align="center"><zb:badge variant="info">In progress</zb:badge></zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">42</zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">64%</zb:table.cell>
</zb:table.row>
<zb:table.row>
<zb:table.cell class="font-medium text-ink">Website</zb:table.cell>
<zb:table.cell>Elif Kaya</zb:table.cell>
<zb:table.cell align="center"><zb:badge variant="success">Completed</zb:badge></zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">37</zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">100%</zb:table.cell>
</zb:table.row>
<zb:table.row>
<zb:table.cell class="font-medium text-ink">Checkout page</zb:table.cell>
<zb:table.cell>Murat Demir</zb:table.cell>
<zb:table.cell align="center"><zb:badge variant="warning">Delayed</zb:badge></zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">51</zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">38%</zb:table.cell>
</zb:table.row>
</zb:table.rows>
</zb:table>
Sorting in a composable table (Livewire)
A column with sortable and field calls your component's sortBy(field) method when clicked; give the sort state to zb:table once. For another method name, put sort-method="sort" on the table.
<zb:table :sort-field="$sortField" :sort-direction="$sortDirection">
<zb:table.columns>
<zb:table.column sortable field="name">Project</zb:table.column>
<zb:table.column sortable field="owner">Owner</zb:table.column>
<zb:table.column sortable field="tasks" align="end">Tasks</zb:table.column>
<zb:table.column align="end">Actions</zb:table.column>
</zb:table.columns>
<zb:table.rows>
@forelse ($projects as $project)
<zb:table.row wire:key="project-{{ $project->id }}">
<zb:table.cell class="font-medium text-ink">{{ $project->name }}</zb:table.cell>
<zb:table.cell>{{ $project->owner }}</zb:table.cell>
<zb:table.cell align="end" class="tabular-nums">{{ $project->tasks }}</zb:table.cell>
<zb:table.cell align="end">
<zb:button size="icon" variant="soft" wire:click="edit({{ $project->id }})" aria-label="Edit" title="Edit">
<zb:icon name="pencil-square" size="4" />
</zb:button>
</zb:table.cell>
</zb:table.row>
@empty
<zb:table.row>
<zb:table.cell colspan="4" align="center" class="text-muted">No projects match this filter.</zb:table.cell>
</zb:table.row>
@endforelse
</zb:table.rows>
</zb:table>
Developer notes
- Cells are single-line by default; give cells with long text
whitespace-normal.text-centersuits short codes and counts. zb:sortable-thtakesmethod="sort"for another method. The matching column's arrow is highlighted,aria-sortis added and the header is a keyboard-usable button.- In the card view the first cell is the title, an end-aligned cell (an amount, a date) moves to its end and the others line up below it; in a composable table the label is
zb:table.cell label. - Without
stack, a table that does not fit scrolls sideways with a shadow on the edge that has more.