Skip to content
Inkoxide

Search covers every page and heading of the docs. Use ↑ ↓ and ↵.

Table

Tables that split across pages and repeat their header rows.

Edit this page

Import them from @inkoxide/react, @inkoxide/vue or @inkoxide/svelte; an Angular template writes them as <ink-table>, <ink-row>, <ink-cell>. Examples, and how these components work together, are in the guide.

Table

A table that splits across pages.

import { Cell, Document, Page, Row, Table } from '@inkoxide/react';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];

export default function Example() {
  return (
    <Document>
      <Page size={[320, 170]} className="p-6 text-xs">
        <Table columns={['1fr', 40, 60]} headerRows={1}>
          <Row className="bg-stone-100 font-bold">
            <Cell className="p-1.5">Item</Cell>
            <Cell className="p-1.5 text-right">Qty</Cell>
            <Cell className="p-1.5 text-right">Amount</Cell>
          </Row>
          {items.map((it) => (
            <Row key={it.name}>
              <Cell className="border-b border-gray-200 p-1.5">{it.name}</Cell>
              <Cell className="border-b border-gray-200 p-1.5 text-right">{it.qty}</Cell>
              <Cell className="border-b border-gray-200 p-1.5 text-right">{it.amount}</Cell>
            </Row>
          ))}
        </Table>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Cell, Document, Page, Row, Table } from '@inkoxide/vue';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];
</script>

<template>
  <Document>
    <Page :size="[320, 170]" class="p-6 text-xs">
      <Table :columns="['1fr', 40, 60]" :headerRows="1">
        <Row class="bg-stone-100 font-bold">
          <Cell class="p-1.5">Item</Cell>
          <Cell class="p-1.5 text-right">Qty</Cell>
          <Cell class="p-1.5 text-right">Amount</Cell>
        </Row>
        <Row v-for="it in items" :key="it.name">
          <Cell class="border-b border-gray-200 p-1.5">{{ it.name }}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{{ it.qty }}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{{ it.amount }}</Cell>
        </Row>
      </Table>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Cell, Document, Page, Row, Table } from '@inkoxide/svelte';

  const items = [
    { name: 'Espresso', qty: 2, amount: '$6.40' },
    { name: 'Almond croissant', qty: 1, amount: '$4.50' },
    { name: 'Sparkling water', qty: 1, amount: '$2.00' },
  ];
</script>

<Document>
  <Page size={[320, 170]} class="p-6 text-xs">
    <Table columns={['1fr', 40, 60]} headerRows={1}>
      <Row class="bg-stone-100 font-bold">
        <Cell class="p-1.5">Item</Cell>
        <Cell class="p-1.5 text-right">Qty</Cell>
        <Cell class="p-1.5 text-right">Amount</Cell>
      </Row>
      {#each items as it (it.name)}
        <Row>
          <Cell class="border-b border-gray-200 p-1.5">{it.name}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{it.qty}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{it.amount}</Cell>
        </Row>
      {/each}
    </Table>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 170]" class="p-6 text-xs">
        <ink-table [columns]="['1fr', 40, 60]" [headerRows]="1">
          <ink-row class="bg-stone-100 font-bold">
            <ink-cell class="p-1.5">Item</ink-cell>
            <ink-cell class="p-1.5 text-right">Qty</ink-cell>
            <ink-cell class="p-1.5 text-right">Amount</ink-cell>
          </ink-row>
          @for (it of items; track it.name) {
            <ink-row>
              <ink-cell class="border-b border-gray-200 p-1.5">{{ it.name }}</ink-cell>
              <ink-cell class="border-b border-gray-200 p-1.5 text-right">{{ it.qty }}</ink-cell>
              <ink-cell class="border-b border-gray-200 p-1.5 text-right">{{ it.amount }}</ink-cell>
            </ink-row>
          }
        </ink-table>
      </ink-page>
    </ink-document>
  `,
})
export class Example {
  readonly items = items;
}
The PDF this example renders.
PropTypeDescription
columns (required)Array<number | string>Column widths: points, '1fr'-style fractions, or 'auto'.
headerRowsnumberRows repeated at the top of every page the table spans.

It also takes the shared props break, wrap, minPresenceAhead, fixed, pages, href, bookmark, className, style, id, debug.

Row

A table that splits across pages.

import { Cell, Document, Page, Row, Table } from '@inkoxide/react';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];

export default function Example() {
  return (
    <Document>
      <Page size={[320, 170]} className="p-6 text-xs">
        <Table columns={['1fr', 40, 60]} headerRows={1}>
          <Row className="bg-stone-100 font-bold">
            <Cell className="p-1.5">Item</Cell>
            <Cell className="p-1.5 text-right">Qty</Cell>
            <Cell className="p-1.5 text-right">Amount</Cell>
          </Row>
          {items.map((it) => (
            <Row key={it.name}>
              <Cell className="border-b border-gray-200 p-1.5">{it.name}</Cell>
              <Cell className="border-b border-gray-200 p-1.5 text-right">{it.qty}</Cell>
              <Cell className="border-b border-gray-200 p-1.5 text-right">{it.amount}</Cell>
            </Row>
          ))}
          <Row className="bg-orange-50 font-bold">
            <Cell className="p-1.5">Total</Cell>
            <Cell className="p-1.5 text-right">4</Cell>
            <Cell className="p-1.5 text-right">$12.90</Cell>
          </Row>
        </Table>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Cell, Document, Page, Row, Table } from '@inkoxide/vue';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];
</script>

<template>
  <Document>
    <Page :size="[320, 170]" class="p-6 text-xs">
      <Table :columns="['1fr', 40, 60]" :headerRows="1">
        <Row class="bg-stone-100 font-bold">
          <Cell class="p-1.5">Item</Cell>
          <Cell class="p-1.5 text-right">Qty</Cell>
          <Cell class="p-1.5 text-right">Amount</Cell>
        </Row>
        <Row v-for="it in items" :key="it.name">
          <Cell class="border-b border-gray-200 p-1.5">{{ it.name }}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{{ it.qty }}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{{ it.amount }}</Cell>
        </Row>
        <Row class="bg-orange-50 font-bold">
          <Cell class="p-1.5">Total</Cell>
          <Cell class="p-1.5 text-right">4</Cell>
          <Cell class="p-1.5 text-right">$12.90</Cell>
        </Row>
      </Table>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Cell, Document, Page, Row, Table } from '@inkoxide/svelte';

  const items = [
    { name: 'Espresso', qty: 2, amount: '$6.40' },
    { name: 'Almond croissant', qty: 1, amount: '$4.50' },
    { name: 'Sparkling water', qty: 1, amount: '$2.00' },
  ];
</script>

<Document>
  <Page size={[320, 170]} class="p-6 text-xs">
    <Table columns={['1fr', 40, 60]} headerRows={1}>
      <Row class="bg-stone-100 font-bold">
        <Cell class="p-1.5">Item</Cell>
        <Cell class="p-1.5 text-right">Qty</Cell>
        <Cell class="p-1.5 text-right">Amount</Cell>
      </Row>
      {#each items as it (it.name)}
        <Row>
          <Cell class="border-b border-gray-200 p-1.5">{it.name}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{it.qty}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{it.amount}</Cell>
        </Row>
      {/each}
      <Row class="bg-orange-50 font-bold">
        <Cell class="p-1.5">Total</Cell>
        <Cell class="p-1.5 text-right">4</Cell>
        <Cell class="p-1.5 text-right">$12.90</Cell>
      </Row>
    </Table>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 170]" class="p-6 text-xs">
        <ink-table [columns]="['1fr', 40, 60]" [headerRows]="1">
          <ink-row class="bg-stone-100 font-bold">
            <ink-cell class="p-1.5">Item</ink-cell>
            <ink-cell class="p-1.5 text-right">Qty</ink-cell>
            <ink-cell class="p-1.5 text-right">Amount</ink-cell>
          </ink-row>
          @for (it of items; track it.name) {
            <ink-row>
              <ink-cell class="border-b border-gray-200 p-1.5">{{ it.name }}</ink-cell>
              <ink-cell class="border-b border-gray-200 p-1.5 text-right">{{ it.qty }}</ink-cell>
              <ink-cell class="border-b border-gray-200 p-1.5 text-right">{{ it.amount }}</ink-cell>
            </ink-row>
          }
          <ink-row class="bg-orange-50 font-bold">
            <ink-cell class="p-1.5">Total</ink-cell>
            <ink-cell class="p-1.5 text-right">4</ink-cell>
            <ink-cell class="p-1.5 text-right">$12.90</ink-cell>
          </ink-row>
        </ink-table>
      </ink-page>
    </ink-document>
  `,
})
export class Example {
  readonly items = items;
}
The PDF this example renders.
PropTypeDescription
classNamestringbg-*, min-h-* and text utilities (inherited by the cells).
styleStyle
idstring
minHeightnumber
debugbooleanOutlines the row's box.

Cell

A table that splits across pages.

import { Cell, Document, Page, Row, Table } from '@inkoxide/react';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];

export default function Example() {
  return (
    <Document>
      <Page size={[320, 170]} className="p-6 text-xs">
        <Table columns={['1fr', 40, 60]} headerRows={1}>
          <Row className="bg-stone-100 font-bold">
            <Cell className="p-1.5">Item</Cell>
            <Cell className="p-1.5 text-right">Qty</Cell>
            <Cell className="p-1.5 text-right">Amount</Cell>
          </Row>
          {items.map((it) => (
            <Row key={it.name}>
              <Cell className="border-b border-gray-200 p-1.5">{it.name}</Cell>
              <Cell className="border-b border-gray-200 p-1.5 text-right">{it.qty}</Cell>
              <Cell className="border-b border-gray-200 p-1.5 text-right">{it.amount}</Cell>
            </Row>
          ))}
          <Row className="font-bold">
            <Cell colSpan={2} className="p-1.5 text-right">
              Total
            </Cell>
            <Cell className="p-1.5 text-right">$12.90</Cell>
          </Row>
        </Table>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Cell, Document, Page, Row, Table } from '@inkoxide/vue';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];
</script>

<template>
  <Document>
    <Page :size="[320, 170]" class="p-6 text-xs">
      <Table :columns="['1fr', 40, 60]" :headerRows="1">
        <Row class="bg-stone-100 font-bold">
          <Cell class="p-1.5">Item</Cell>
          <Cell class="p-1.5 text-right">Qty</Cell>
          <Cell class="p-1.5 text-right">Amount</Cell>
        </Row>
        <Row v-for="it in items" :key="it.name">
          <Cell class="border-b border-gray-200 p-1.5">{{ it.name }}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{{ it.qty }}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{{ it.amount }}</Cell>
        </Row>
        <Row class="font-bold">
          <Cell :colSpan="2" class="p-1.5 text-right">
            Total
          </Cell>
          <Cell class="p-1.5 text-right">$12.90</Cell>
        </Row>
      </Table>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Cell, Document, Page, Row, Table } from '@inkoxide/svelte';

  const items = [
    { name: 'Espresso', qty: 2, amount: '$6.40' },
    { name: 'Almond croissant', qty: 1, amount: '$4.50' },
    { name: 'Sparkling water', qty: 1, amount: '$2.00' },
  ];
</script>

<Document>
  <Page size={[320, 170]} class="p-6 text-xs">
    <Table columns={['1fr', 40, 60]} headerRows={1}>
      <Row class="bg-stone-100 font-bold">
        <Cell class="p-1.5">Item</Cell>
        <Cell class="p-1.5 text-right">Qty</Cell>
        <Cell class="p-1.5 text-right">Amount</Cell>
      </Row>
      {#each items as it (it.name)}
        <Row>
          <Cell class="border-b border-gray-200 p-1.5">{it.name}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{it.qty}</Cell>
          <Cell class="border-b border-gray-200 p-1.5 text-right">{it.amount}</Cell>
        </Row>
      {/each}
      <Row class="font-bold">
        <Cell colSpan={2} class="p-1.5 text-right">
          Total
        </Cell>
        <Cell class="p-1.5 text-right">$12.90</Cell>
      </Row>
    </Table>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

const items = [
  { name: 'Espresso', qty: 2, amount: '$6.40' },
  { name: 'Almond croissant', qty: 1, amount: '$4.50' },
  { name: 'Sparkling water', qty: 1, amount: '$2.00' },
];

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 170]" class="p-6 text-xs">
        <ink-table [columns]="['1fr', 40, 60]" [headerRows]="1">
          <ink-row class="bg-stone-100 font-bold">
            <ink-cell class="p-1.5">Item</ink-cell>
            <ink-cell class="p-1.5 text-right">Qty</ink-cell>
            <ink-cell class="p-1.5 text-right">Amount</ink-cell>
          </ink-row>
          @for (it of items; track it.name) {
            <ink-row>
              <ink-cell class="border-b border-gray-200 p-1.5">{{ it.name }}</ink-cell>
              <ink-cell class="border-b border-gray-200 p-1.5 text-right">{{ it.qty }}</ink-cell>
              <ink-cell class="border-b border-gray-200 p-1.5 text-right">{{ it.amount }}</ink-cell>
            </ink-row>
          }
          <ink-row class="font-bold">
            <ink-cell [colSpan]="2" class="p-1.5 text-right">
              Total
            </ink-cell>
            <ink-cell class="p-1.5 text-right">$12.90</ink-cell>
          </ink-row>
        </ink-table>
      </ink-page>
    </ink-document>
  `,
})
export class Example {
  readonly items = items;
}
The PDF this example renders.
PropTypeDescription
colSpannumber
rowSpannumber
verticalAlign'top' | 'middle' | 'bottom'
headerbooleanIn tagged output, a header of its row; the cells of header rows head their columns.

It also takes the shared props className, style, id, debug.

Synced from components/table.md in the inkoxide repository.