Data display
Data list
Label and value pairs, such as the details of a record on its page: a grid with the label above each value, or rows with the label at the start and the value at the end. Renders a <dl>.
Nothing to show
Two columns from the sm breakpoint (one on phones), each pair with the label in muted text and the value under it. A pair whose value is empty shows "—" in place of the value.
In rows #
One pair per row, the label at the start and the value at the end, with a line between the rows.
Nothing to show
Values with markup #
Pairs written by hand: the slot of tk:data-list.item is its value, so it can hold any markup. They come before the pairs from items.
Nothing to show
From data, with options per pair #
A value that is an array with keys is a set of tk:data-list.item props for that pair; the key is its label. A list of values (['Admin', 'Editor']) is joined with commas.
Nothing to show
When there is nothing to show #
With no pairs, an empty state takes the place of the list: an icon and "No contacts yet", centered. Without empty it says "No records found".
No contacts yet
Nothing to show
Hiding empty values #
:placeholder="false" leaves out the pairs whose value is empty instead of showing "—".
Nothing to show
Customization #
label: and value: reach each label and value; item: each pair from items.
Nothing to show
Reference
tk:data-list
└── tk:data-list.item ...
tk:data-list
| Prop | Type | Default | Description |
|---|---|---|---|
items |
array | Collection | null |
The pairs, as label => value. Labels are translated; values are printed as text (an Htmlable value as HTML). |
columns |
int | 1 |
2, 3 or 4 columns in the grid, from the sm breakpoint (3 and 4 show two columns until lg). Ignored with inline. |
inline |
bool | false |
One pair per row, the label at the start and the value at the end. |
divided |
bool | false |
A line between the pairs, in place of the gap. Meant for one column or inline. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Sets the text size and the spacing; inherited by the pairs. |
placeholder |
string | false | — |
Shown in place of an empty value. false leaves out the pairs with an empty value. Inherited by the pairs. |
empty |
string | slot | false | No records found |
With no pairs: the title of the empty state shown instead, or a slot that replaces it. false renders nothing. |
Slots
| Slot | Description |
|---|---|
| default | tk:data-list.item pairs, before those from items. |
empty |
Replaces the empty state when there are no pairs. |
tk:data-list.item
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string | slot | null |
The label, translated. |
value |
string | slot | null |
The value. The default slot takes its place when it has content. |
icon |
string | slot | null |
An icon before the label. |
size, inline, divided and placeholder are inherited from the tk:data-list around it.
Slots
| Slot | Description |
|---|---|
| default | The value, in place of value. |
Customization
Classes and attributes on tk:data-list go to the <dl>, and to the empty state's box when it shows instead. The parts take prefixes:
| Prefix | Tag | Goes to |
|---|---|---|
item: |
tk:data-list |
Each pair from items (the <div> around its <dt> and <dd>). |
label: |
tk:data-list, tk:data-list.item |
The label, a <dt>. |
value: |
tk:data-list, tk:data-list.item |
The value, a <dd>. |
empty: |
tk:data-list |
The tk:empty shown with no pairs (empty:icon="mdi:account-off"). |
On tk:data-list, item:, label: and value: reach the pairs from items; a pair written by hand takes them on its own tag.
Nothing to show
Accessibility
A <dl> with a <dt> and a <dd> for each pair, grouped in a <div>, which screen readers announce as a description list. The "—" of an empty value is hidden from screen readers, which read "Not provided" instead; the label icon is hidden too.
Behavior notes
- A value is empty when it is
null,'',falseor an empty slot;0is shown. - A key with an array of props can set
labelitself ('tax' => ['label' => 'Tax id', 'value' => $taxId]), which wins over the key. A list without string keys can be made of such arrays. - The pairs from
itemshave awire:keyfrom their position, so a Livewire update that adds or removes pairs patches the list in place.