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.
| Invoice | Status | Amount |
|---|---|---|
| INV-1042 | Paid | ₹12,400 |
| INV-1041 | Pending | ₹8,250 |
| INV-1040 | Overdue | ₹3,100 |
| INV-1039 | Paid | ₹15,000 |
<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>| Invoice | Status | Amount |
|---|---|---|
| INV-1042 | Paid | ₹12,400 |
| INV-1041 | Pending | ₹8,250 |
| INV-1040 | Overdue | ₹3,100 |
| INV-1039 | Paid | ₹15,000 |
import { Table } from "@/components/vin/table";
import { Badge } from "@/components/vin/badge";
const rows = [
["INV-1042", "success", "Paid", "₹12,400"],
["INV-1041", "warning", "Pending", "₹8,250"],
["INV-1040", "danger", "Overdue", "₹3,100"],
["INV-1039", "success", "Paid", "₹15,000"],
] as const;
export function TableBasic() {
return (
<Table caption="Recent invoices" style={{ maxWidth: 480 }}>
<thead>
<tr><th scope="col">Invoice</th><th scope="col">Status</th><th scope="col" className="vin-table__num">Amount</th></tr>
</thead>
<tbody>
{rows.map(([id, variant, status, amount]) => (
<tr key={id}><td>{id}</td><td><Badge variant={variant}>{status}</Badge></td><td className="vin-table__num">{amount}</td></tr>
))}
</tbody>
</Table>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Table from "@/components/vin/table.vue";
import Badge from "@/components/vin/badge.vue";
const rows = [
["INV-1042", "success", "Paid", "₹12,400"],
["INV-1041", "warning", "Pending", "₹8,250"],
["INV-1040", "danger", "Overdue", "₹3,100"],
["INV-1039", "success", "Paid", "₹15,000"],
] as const;
</script>
<template>
<Table caption="Recent invoices" style="max-width: 480px">
<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 v-for="[id, variant, status, amount] in rows" :key="id">
<td>{{ id }}</td><td><Badge :variant="variant">{{ status }}</Badge></td><td class="vin-table__num">{{ amount }}</td>
</tr>
</tbody>
</Table>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Table from "$lib/components/vin/table.svelte";
import Badge from "$lib/components/vin/badge.svelte";
const rows = [
["INV-1042", "success", "Paid", "₹12,400"],
["INV-1041", "warning", "Pending", "₹8,250"],
["INV-1040", "danger", "Overdue", "₹3,100"],
["INV-1039", "success", "Paid", "₹15,000"],
] as const;
</script>
<Table caption="Recent invoices" style="max-width: 480px">
<thead>
<tr><th scope="col">Invoice</th><th scope="col">Status</th><th scope="col" class="vin-table__num">Amount</th></tr>
</thead>
<tbody>
{#each rows as [id, variant, status, amount] (id)}
<tr><td>{id}</td><td><Badge {variant}>{status}</Badge></td><td class="vin-table__num">{amount}</td></tr>
{/each}
</tbody>
</Table>With a footer
A footer row for totals.
Striped
Shaded rows help the eye follow long rows.
| Name | Role | Joined |
|---|---|---|
| Ada | Owner | 2023 |
| Alan | Admin | 2024 |
| Grace | Editor | 2024 |
| Katherine | Editor | 2025 |
| Linus | Viewer | 2026 |
<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>| Name | Role | Joined |
|---|---|---|
| Ada | Owner | 2023 |
| Alan | Admin | 2024 |
| Grace | Editor | 2024 |
| Katherine | Editor | 2025 |
| Linus | Viewer | 2026 |
import { Table } from "@/components/vin/table";
const team = [["Ada", "Owner", 2023], ["Alan", "Admin", 2024], ["Grace", "Editor", 2024], ["Katherine", "Editor", 2025], ["Linus", "Viewer", 2026]] as const;
export function TableStriped() {
return (
<Table label="Team" striped style={{ maxWidth: 480 }}>
<thead>
<tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col" className="vin-table__num">Joined</th></tr>
</thead>
<tbody>
{team.map(([name, role, year]) => (
<tr key={name}><td>{name}</td><td>{role}</td><td className="vin-table__num">{year}</td></tr>
))}
</tbody>
</Table>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Table from "@/components/vin/table.vue";
const team = [["Ada", "Owner", 2023], ["Alan", "Admin", 2024], ["Grace", "Editor", 2024], ["Katherine", "Editor", 2025], ["Linus", "Viewer", 2026]] as const;
</script>
<template>
<Table label="Team" striped style="max-width: 480px">
<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 v-for="[name, role, year] in team" :key="name">
<td>{{ name }}</td><td>{{ role }}</td><td class="vin-table__num">{{ year }}</td>
</tr>
</tbody>
</Table>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Table from "$lib/components/vin/table.svelte";
const team = [["Ada", "Owner", 2023], ["Alan", "Admin", 2024], ["Grace", "Editor", 2024], ["Katherine", "Editor", 2025], ["Linus", "Viewer", 2026]] as const;
</script>
<Table label="Team" striped style="max-width: 480px">
<thead>
<tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col" class="vin-table__num">Joined</th></tr>
</thead>
<tbody>
{#each team as [name, role, year] (name)}
<tr><td>{name}</td><td>{role}</td><td class="vin-table__num">{year}</td></tr>
{/each}
</tbody>
</Table>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:
npx @vinish/ui add tableimport { Table } from "@/components/vin/table";import Table from "@/components/vin/table.vue";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.
| Prop | Values | Default | In HTML |
|---|---|---|---|
striped | boolean | false | vin-table--striped |
captionSays what the table shows. Shown under the table. | ReactNode | — | <caption class="vin-table__caption"> |
numeric cellsRight-align numbers so the digits line up. | class | — | th / td class="vin-table__num" |
Parts
| React, Vue, Svelte | HTML 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).
Customize
Saved in this browser. Style and accent are in the header.