Table

Displays data in a structured table format with styling variants and semantic HTML structure.

PreviousNext
A list of your recent invoices.
NameAgeAddress
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sidney No. 1 Lake Park

Installation

1

Run the CLI

Use the CLI to add the component to your project.

npx @ngzard/ui@latest add table

Examples

simple

A list of your recent invoices.
NameAgeAddress
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sidney No. 1 Lake Park

payments

StatusEmailAmountActions
success
ken99@example.com
$316.00
success
Abe45@example.com
$242.00
processing
Monserrat44@example.com
$837.00
success
Silas22@example.com
$874.00
failed
carmella@example.com
$721.00
pending
jane.doe@example.com
$456.00

API

[z-table] Directive

z-table is a directive that accepts all properties supported by a native <table>. It automatically styles all nested table elements (thead, tbody, tr, th, td, caption) without requiring additional directives.

To customize the table, pass the following props to the directive.

Property Description Type Default
zType Table type default | striped | bordered default
zSize Table size default | compact | comfortable default

Usage

Basic Table

<table z-table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Email</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>john@example.com</td>
      <td>Active</td>
    </tr>
  </tbody>
</table>

With Data Binding

<table z-table zType="striped">
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody>
    @for (person of people; track person.id) {
    <tr>
      <td>{{ person.name }}</td>
      <td>{{ person.age }}</td>
    </tr>
    }
  </tbody>
</table>

Optional Sub-Components

For more granular control, you can use individual table components:

[z-table-header] Component

thead[z-table-header] applies styles to table header sections.

[z-table-body] Component

tbody[z-table-body] applies styles to table body sections.

[z-table-row] Component

tr[z-table-row] applies styles to table rows.

[z-table-head] Component

th[z-table-head] applies styles to table header cells.

[z-table-cell] Component

td[z-table-cell] applies styles to table data cells.

[z-table-caption] Component

caption[z-table-caption] applies styles to table captions.