Table
Neo-brutalist data table with 8 composable sub-components for structured tabular data display. Built on native HTML table elements, supporting header variants, footer variants, and accessibility labels.
Demo
| 名称 | 状态 | 金额 |
|---|---|---|
| 发票 #001 | 已支付 | $250.00 |
| 发票 #002 | 待处理 | $150.00 |
自定义 aria-label
| 名称 | 金额 |
|---|---|
| 发票 #001 | $250.00 |
| 发票 #002 | $150.00 |
表头底纹(texture)
| 剖面线 | HATCH |
|---|---|
| A-01 | ¥ 120 |
| 点阵 | DOTS |
|---|---|
| B-02 | ¥ 340 |
Installation
pnpm dlx brutx-vue@latest add tableUsage
<script setup>
import { Table, TableHeader, TableBody, TableHead, TableRow, TableCell, TableCaption, TableFooter } from 'brutx-ui-vue'
</script>
<template>
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead class="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead class="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell class="font-medium">INV001</TableCell>
<TableCell>Paid</TableCell>
<TableCell class="text-right">$250.00</TableCell>
</TableRow>
<TableRow>
<TableCell class="font-medium">INV002</TableCell>
<TableCell>Pending</TableCell>
<TableCell class="text-right">$150.00</TableCell>
</TableRow>
</TableBody>
<TableFooter>
<TableRow>
<TableCell colspan="2">Total</TableCell>
<TableCell class="text-right">$400.00</TableCell>
</TableRow>
</TableFooter>
</Table>
</template>Sub-components
| Component | Description |
|---|---|
Table | Root table container with border and shadow |
TableHeader | Header area (<thead>) |
TableBody | Body area (<tbody>) |
TableFooter | Footer area (<tfoot>) |
TableRow | Table row (<tr>) with bottom border |
TableHead | Header cell (<th>) with bold text |
TableCell | Data cell (<td>) |
TableCaption | Table caption (<caption>) |
API Reference
Table
| Name | Type | Default | Description |
|---|---|---|---|
class | string | undefined | — | Custom CSS classes appended to the native table element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/Table.vue | |||
ariaLabel | string | undefined | — | Sets aria-label on the native table element to provide an accessible name. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/Table.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Composes table structure children such as TableHeader, TableBody, and TableFooter. |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/Table.vue | ||
TableBody
| Name | Type | Default | Description |
|---|---|---|---|
class | string | undefined | — | Custom CSS classes appended to the native tbody element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/TableBody.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Contains table rows rendered with TableRow. |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/TableBody.vue | ||
TableCaption
| Name | Type | Default | Description |
|---|---|---|---|
class | string | undefined | — | Custom CSS classes appended to the native caption element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/TableCaption.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Renders a table caption or summary. |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/TableCaption.vue | ||
TableCell
| Name | Type | Default | Description |
|---|---|---|---|
class | string | undefined | — | Custom CSS classes appended to the native td element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/TableCell.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Renders table data cell content. |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/TableCell.vue | ||
TableHead
| Name | Type | Default | Description |
|---|---|---|---|
variant | "default" | "primary" | "secondary" | undefined | undefined | Selects the default, primary, or secondary style for a header cell. |
DetailsDeclared typeNonNullable<"default" | "primary" | "secondary" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/table/TableHead.vue | |||
class | string | undefined | undefined | Custom CSS classes appended to the native th element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/TableHead.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Renders header cell content. The element sets scope="col". |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/TableHead.vue | ||
TableHeader
| Name | Type | Default | Description |
|---|---|---|---|
variant | "default" | "primary" | "secondary" | undefined | "default" | Selects the default, primary, or secondary style for the table header. |
DetailsDeclared typeNonNullable<"default" | "primary" | "secondary" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/table/TableHeader.vue | |||
texture | "dots" | "hatch" | "none" | undefined | "none" | Selects no texture, hatch lines, or dots for the table header. The texture is layered over the selected color variant. |
DetailsDeclared typeNonNullable<"none" | "dots" | "hatch" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/table/TableHeader.vue | |||
class | string | undefined | undefined | Custom CSS classes appended to the native thead element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/TableHeader.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Contains header rows rendered with TableRow. |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/TableHeader.vue | ||
TableRow
| Name | Type | Default | Description |
|---|---|---|---|
class | string | undefined | — | Custom CSS classes appended to the native tr element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/table/TableRow.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Contains header cells or data cells. |
DetailsDeclared type{}Sourcepackages/ui/src/components/table/TableRow.vue | ||
Accessibility
- ARIA Attributes: Use
ariaLabelto provide a readable name for the table, helping screen readers identify the table's purpose. This is especially important for tables without a visible caption (TableCaption).ariaLabelonly applies to theTableroot component.
<script setup>
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from 'brutx-ui-vue'
</script>
<template>
<Table ariaLabel="Recent invoices list">
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>Invoice #001</TableCell>
<TableCell>$250.00</TableCell>
</TableRow>
</TableBody>
</Table>
</template>- Semantic Markup: Uses native
<table>,<thead>,<tbody>,<tfoot>,<th>,<td>,<caption>elements to ensure assistive technologies correctly parse the table structure.