Data display

Table

@xui/table

A data table. Layout is flex rather than table-layout, so a column can grow while the rest stay sized to their content, and the row parts stay addressable for striping and selection.

Install

pnpm add @xui/table

Add the barrel to a standalone component's imports:

import { XuiTableImports } from '@xui/table';@Component({  imports: [XuiTableImports],  // …})

Examples

Default

Loading preview…

Modifiers

Loading preview…

Cdktable

Source only — this one needs a component of its own to run, so there is nothing to render here.

<x-table  xuiTable  stickyHeader  [dataSource]="users()"  [displayedColumns]="columns.displayedColumns()"  [trackBy]="trackBy">  <x-column-def name="name" class="w-40">    <xui-th *xHeaderDef>Name</xui-th>    <xui-td truncate *xCellDef="let user">{{ user.name }}</xui-td>  </x-column-def>  <x-column-def name="gender" class="w-40 justify-center">    <xui-th *xHeaderDef>Gender</xui-th>    <xui-td truncate *xCellDef="let user">{{ user.gender }}</xui-td>  </x-column-def>  <x-column-def name="weight">    <xui-th *xHeaderDef>Weight</xui-th>    <xui-td *xCellDef="let user">{{ user.weight }}</xui-td>  </x-column-def></x-table><ng-template  xPaginator  [xPaginatorTotalElements]="totalElements()"  [xPaginatorPageSize]="pageSize()"  (xPaginatorStateChange)="onStateChange($event)"  let-ctx>  <div class="mt-2 flex items-center justify-between">    <span class="text-sm tabular-nums">      Showing entries {{ ctx.state().startIndex + 1 }} - {{ ctx.state().endIndex + 1 }} of {{ totalElements() }}    </span>    <div class="flex">      <select        [ngModel]="pageSize()"        (ngModelChange)="pageSize.set($event)"        xuiInput        size="sm"        class="mr-1 inline-flex pr-8"      >        <option [value]="size" *ngFor="let size of availablePageSizes">{{ size === 10000 ? 'All' : size }}</option>      </select>      <div class="flex space-x-1">        <button size="sm" variant="outline" xuiButton [disabled]="!ctx.decrementable()" (click)="ctx.decrement()">          Previous        </button>        <button size="sm" variant="outline" xuiButton [disabled]="!ctx.incrementable()" (click)="ctx.increment()">          Next        </button>      </div>    </div>  </div></ng-template>

API

XuiCaption

componentxui-caption

The table's accessible name.

Inputs

NameTypeDefaulthiddenbooleanTake the caption off screen while keeping it as the table's accessible name. Use it when the surrounding page already carries a visible heading.falseclassClassValueExtra classes, merged into the component's own rather than replacing them.''

XuiTableClasses

directive[xuiTable]

Styles the headless <x-table> by writing the xUI Tailwind classes into its tableClasses/headerRowClasses/bodyRowClasses model inputs: <x-table xuiTable>. A consumer binding those inputs itself wins, since the input binding is applied after this constructor runs.

XuiTable

componentxui-table

A table laid out with flex rather than table-layout, so a column can grow while the rest stay sized to their content and the row parts stay addressable for striping and selection.

Variants

AxisOptionsDefaultstripedtruefalsefalseborderedtruefalsefalseinteractivetruefalsefalsecompacttruefalsefalse

Inputs

NameTypeDefaultclassClassValueExtra classes, merged into the component's own rather than replacing them.''stripedbooleanAlternate row background.this.config.stripedborderedbooleanOuter border plus dividers between cells.this.config.borderedinteractivebooleanShow a pointer cursor on rows for clickable tables.this.config.interactivecompactbooleanTighter cell padding.this.config.compactaria-labelledbystring | null | undefinedId of the element naming the table. Usually left alone: a projected xui-caption sets this itself.undefined

XuiTd

componentxui-td

One body cell of a xui-table.

Inputs

NameTypeDefaulttruncatebooleanClip overflowing content to one line with an ellipsis, instead of letting the cell grow.falseclassClassValueExtra classes, merged into the component's own rather than replacing them.''

XuiTh

componentxui-th

One header cell of a xui-table.

Inputs

NameTypeDefaulttruncatebooleanClip an overlong heading to one line with an ellipsis, instead of letting the header row grow.falseclassClassValueExtra classes, merged into the component's own rather than replacing them.''

XuiTr

componentxui-tr

One row of a xui-table, header or body.

Inputs

NameTypeDefaultclassClassValueExtra classes, merged into the component's own rather than replacing them.''

Source

libs/ui/table/xui

xUI 3.0.0 — Apache 2.0 licensed. Built with Angular and Tailwind CSS.