Skip to content

Table

Rows and columns of data, with a header, an optional footer and a caption. Same markup and props in every style: switch the style in the header to see it change.

Basic

A header row, badges for status and right-aligned amounts. The caption names the table.

Recent invoices
InvoiceStatusAmount
INV-1042Paid₹12,400
INV-1041Pending₹8,250
INV-1040Overdue₹3,100
INV-1039Paid₹15,000
table-basic.html
<div class="vin-table-wrap" role="region" aria-label="Recent invoices" tabindex="0" style="max-width: 480px">
  <table class="vin-table">
    <caption class="vin-table__caption">Recent invoices</caption>
    <thead>
      <tr><th scope="col">Invoice</th><th scope="col">Status</th><th scope="col" class="vin-table__num">Amount</th></tr>
    </thead>
    <tbody>
      <tr><td>INV-1042</td><td><span class="vin-badge vin-badge--success">Paid</span></td><td class="vin-table__num">₹12,400</td></tr>
      <tr><td>INV-1041</td><td><span class="vin-badge vin-badge--warning">Pending</span></td><td class="vin-table__num">₹8,250</td></tr>
      <tr><td>INV-1040</td><td><span class="vin-badge vin-badge--danger">Overdue</span></td><td class="vin-table__num">₹3,100</td></tr>
      <tr><td>INV-1039</td><td><span class="vin-badge vin-badge--success">Paid</span></td><td class="vin-table__num">₹15,000</td></tr>
    </tbody>
  </table>
</div>

A footer row for totals.

Striped

Shaded rows help the eye follow long rows.

NameRoleJoined
AdaOwner2023
AlanAdmin2024
GraceEditor2024
KatherineEditor2025
LinusViewer2026
table-striped.html
<div class="vin-table-wrap" role="region" aria-label="Team" tabindex="0" style="max-width: 480px">
  <table class="vin-table vin-table--striped">
    <thead>
      <tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col" class="vin-table__num">Joined</th></tr>
    </thead>
    <tbody>
      <tr><td>Ada</td><td>Owner</td><td class="vin-table__num">2023</td></tr>
      <tr><td>Alan</td><td>Admin</td><td class="vin-table__num">2024</td></tr>
      <tr><td>Grace</td><td>Editor</td><td class="vin-table__num">2024</td></tr>
      <tr><td>Katherine</td><td>Editor</td><td class="vin-table__num">2025</td></tr>
      <tr><td>Linus</td><td>Viewer</td><td class="vin-table__num">2026</td></tr>
    </tbody>
  </table>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add table
React
import { Table } from "@/components/vin/table";
Vue
import Table from "@/components/vin/table.vue";
Svelte
import Table from "$lib/components/vin/table.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/table.json, which every framework version is tested against.

PropValuesDefaultIn HTML
stripedbooleanfalsevin-table--striped
caption
Says what the table shows. Shown under the table.
ReactNode—<caption class="vin-table__caption">
numeric cells
Right-align numbers so the digits line up.
class—th / td class="vin-table__num"

Parts

React, Vue, SvelteHTML classes
<Table>.vin-table-wrap.vin-table.vin-table--striped.vin-table__caption.vin-table__num

Accessibility

  • A real <table> with <th scope="col"> headers, so screen readers read the column name with each cell.
  • The caption names the table; screen readers read it first even though it's shown underneath.
  • On small screens the table scrolls sideways inside its frame instead of squashing the columns. The frame can be scrolled with the keyboard (tabindex="0" with a label).