Skip to content

Table

A responsive table component for displaying tabular data.

NameEmailRoleStatus
John Doejohn@example.comAdminactive
Jane Smithjane@example.comUseractive
Bob Johnsonbob@example.comUserinactive

Cài đặt

bash
npx @galaxy-stack/nebula-cli add table
bash
npx @galaxy-stack/nebula-cli add table
bash
npx @galaxy-stack/nebula-cli add table

Usage

tsx
import {
  Table,
  TableHeader,
  TableBody,
  TableFooter,
  TableHead,
  TableRow,
  TableCell,
  TableCaption,
} from '@/components/table'

export default function TableDemo() {
  return (
    <Table>
      <TableCaption>A list of your recent invoices.</TableCaption>
      <TableHeader>
        <TableRow>
          <TableHead>Invoice</TableHead>
          <TableHead>Status</TableHead>
          <TableHead>Method</TableHead>
          <TableHead className="text-right">Amount</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell className="font-medium">INV001</TableCell>
          <TableCell>Paid</TableCell>
          <TableCell>Credit Card</TableCell>
          <TableCell className="text-right">$250.00</TableCell>
        </TableRow>
      </TableBody>
      <TableFooter>
        <TableRow>
          <TableCell colSpan={3}>Total</TableCell>
          <TableCell className="text-right">$2,500.00</TableCell>
        </TableRow>
      </TableFooter>
    </Table>
  )
}
vue
<script setup lang="ts">
import {
  Table,
  TableHeader,
  TableBody,
  TableFooter,
  TableHead,
  TableRow,
  TableCell,
  TableCaption,
} from '@/components/table'
</script>

<template>
  <Table>
    <TableCaption>A list of your recent invoices.</TableCaption>
    <TableHeader>
      <TableRow>
        <TableHead>Invoice</TableHead>
        <TableHead>Status</TableHead>
        <TableHead>Method</TableHead>
        <TableHead class="text-right">Amount</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow>
        <TableCell class="font-medium">INV001</TableCell>
        <TableCell>Paid</TableCell>
        <TableCell>Credit Card</TableCell>
        <TableCell class="text-right">$250.00</TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
typescript
import { Component } from '@angular/core'
import {
  TableComponent,
  TableHeaderDirective,
  TableBodyDirective,
  TableRowDirective,
  TableHeadDirective,
  TableCellDirective,
  TableCaptionDirective,
} from '@/components/table'

@Component({
  selector: 'app-table-demo',
  standalone: true,
  imports: [
    TableComponent,
    TableHeaderDirective,
    TableBodyDirective,
    TableRowDirective,
    TableHeadDirective,
    TableCellDirective,
    TableCaptionDirective,
  ],
  template: `
    <ui-table>
      <caption uiTableCaption>A list of your recent invoices.</caption>
      <thead uiTableHeader>
        <tr uiTableRow>
          <th uiTableHead>Invoice</th>
          <th uiTableHead>Status</th>
          <th uiTableHead>Method</th>
          <th uiTableHead class="text-right">Amount</th>
        </tr>
      </thead>
      <tbody uiTableBody>
        <tr uiTableRow>
          <td uiTableCell class="font-medium">INV001</td>
          <td uiTableCell>Paid</td>
          <td uiTableCell>Credit Card</td>
          <td uiTableCell class="text-right">$250.00</td>
        </tr>
      </tbody>
    </ui-table>
  `
})
export class TableDemo {}

API Reference

Table Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho phần tử tableAll
childrenReactNode-Nội dung composition của tableAll

TableHeader Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho section headerAll
childrenReactNode-Các hàng headerAll

TableBody Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho section bodyAll
childrenReactNode-Các hàng bodyAll

TableFooter Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho section footerAll
childrenReactNode-Các hàng footerAll

TableRow Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho hàngAll
childrenReactNode-Các ô trong hàngAll

TableHead Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho ô headerAll
childrenReactNode-Nội dung ô headerAll

TableCell Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho ôAll
childrenReactNode-Nội dung ôAll

TableCaption Props

PropTypeDefaultMô tảFrameworks
classNamestring''CSS class cho captionAll
childrenReactNode-Văn bản captionAll

Components

Table component bao gồm các sub-components:

  • Table - Container wrapper chính với responsive
  • TableHeader - Section header của table
  • TableBody - Section body của table
  • TableFooter - Section footer của table
  • TableRow - Hàng của table với hiệu ứng hover
  • TableHead - Ô header của table
  • TableCell - Ô body của table
  • TableCaption - Caption mô tả tùy chọn
  • TableCaption - Table caption

Accessibility

  • Uses semantic HTML table elements
  • Proper heading structure with <thead> and <th>
  • Caption provides context for screen readers

Tác giả

Bùi Trọng Hiếu (kevinbui)

Giấy phép

MIT © 2025 Bùi Trọng Hiếu (kevinbui)

Phát hành theo Giấy phép MIT.