Skip to main content
2.0.61
Light Dark System
Compact Comfortable

Table

<zn-table> ZnTable
Since 1.0 experimental

Tables render rows from JSON data, with optional row actions and a fixed first column.

{ “header”: [“Name”, “Email”, “Role”, “Joined”], “items”: [ {“caption”: “Jane Cooper”, “summary”: “Billing”, “icon”: “person”, “data”: [“jane@example.com”, “Admin”, “2025–01–04″]}, {“caption”: “Cody Fisher”, “summary”: “Support”, “icon”: “person”, “data”: [“cody@example.com”, “Member”, “2025–02–11″]}, {“caption”: “Esther Howard”, “summary”: “Sales”, “icon”: “person”, “data”: [“esther@example.com”, “Member”, “2025–03–27″]} ] }
<zn-table>
{
  "header": ["Name", "Email", "Role", "Joined"],
  "items": [
    {"caption": "Jane Cooper", "summary": "Billing", "icon": "person", "data": ["jane@example.com", "Admin", "2025-01-04"]},
    {"caption": "Cody Fisher", "summary": "Support", "icon": "person", "data": ["cody@example.com", "Member", "2025-02-11"]},
    {"caption": "Esther Howard", "summary": "Sales", "icon": "person", "data": ["esther@example.com", "Member", "2025-03-27"]}
  ]
}
</zn-table>

Pass the table as JSON, either in the data attribute or as the element’s text content as above. header names the columns. Each item fills one row: the first column shows its caption, with an optional summary under it and an icon before it, and data fills the remaining columns in order.

Examples

Linked Rows

Give an item a uri to make the whole row a link to it.

{ “header”: [“Invoice”, “Amount”, “Status”], “items”: [ {“caption”: “INV-1042”, “uri”: ”#inv-1042″, “data”: [”£120.00″, “Paid”]}, {“caption”: “INV-1043”, “uri”: ”#inv-1043″, “data”: [”£80.00″, “Due”]} ] }
<zn-table>
{
  "header": ["Invoice", "Amount", "Status"],
  "items": [
    {"caption": "INV-1042", "uri": "#inv-1042", "data": ["£120.00", "Paid"]},
    {"caption": "INV-1043", "uri": "#inv-1043", "data": ["£80.00", "Due"]}
  ]
}
</zn-table>

Row Actions

Give an item actions to add a menu to its row. Each action has a title and a path; add confirm to ask before it runs.

{ “header”: [“Name”, “Email”, “State”], “items”: [ { “caption”: “John Doe”, “data”: [“john.doe@example.com”, “Suspended”], “actions”: [ {“title”: “View profile”, “path”: ”#profile”}, {“title”: “Reactivate”, “confirm”: {“type”: “success”, “trigger”: “reactivate-john”, “caption”: “Reactivate access”, “content”: “Reactivate access for John Doe?”, “action”: ”#”}} ] }, {“caption”: “Jane Cooper”, “data”: [“jane@example.com”, “Active”]} ] }
<zn-table>
{
  "header": ["Name", "Email", "State"],
  "items": [
    {
      "caption": "John Doe",
      "data": ["john.doe@example.com", "Suspended"],
      "actions": [
        {"title": "View profile", "path": "#profile"},
        {"title": "Reactivate", "confirm": {"type": "success", "trigger": "reactivate-john", "caption": "Reactivate access", "content": "Reactivate access for John Doe?", "action": "#"}}
      ]
    },
    {"caption": "Jane Cooper", "data": ["jane@example.com", "Active"]}
  ]
}
</zn-table>

Yes/No Columns

Add bool-icons to show true and false values as a tick and a cross.

{ “header”: [“Feature”, “Starter”, “Pro”], “items”: [ {“caption”: “API access”, “data”: [false, true]}, {“caption”: “Priority support”, “data”: [false, true]}, {“caption”: “Exports”, “data”: [true, true]} ] }
<zn-table bool-icons>
{
  "header": ["Feature", "Starter", "Pro"],
  "items": [
    {"caption": "API access", "data": [false, true]},
    {"caption": "Priority support", "data": [false, true]},
    {"caption": "Exports", "data": [true, true]}
  ]
}
</zn-table>

Layout Options

Add headless to hide the header row, left-align to left-align every column, and fixed-first to keep the first column in place while the rest scroll sideways.

{ “header”: [“Setting”, “Value”], “items”: [ {“caption”: “Timezone”, “data”: [“Europe/London”]}, {“caption”: “Currency”, “data”: [“GBP”]} ] }
<zn-table headless left-align>
{
  "header": ["Setting", "Value"],
  "items": [
    {"caption": "Timezone", "data": ["Europe/London"]},
    {"caption": "Currency", "data": ["GBP"]}
  ]
}
</zn-table>