We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Table Component

The Table component offers two flexible approaches for creating tables: a high-level component for simple data display and a composable API for complex custom tables.

  • Check Circle

    Two Usage Methods: High-level component or composable parts

  • Check Circle

    Rich Styling: Striped rows, borders, and hover states

  • Check Circle

    Accessibility: Semantic markup and ARIA support

  • Check Circle

    Dynamic Data: Support for headers, body, and footer

Perfect for simple data tables:

<Table
headers={{
columns: ['Name', 'Role', 'Department'],
}}
body={[
['John Doe', 'Developer', 'Engineering'],
['Jane Smith', 'Designer', 'Creative'],
['Mike Johnson', 'Manager', 'Operations'],
]}
/>

For more complex tables with custom markup:

<Table.Root striped borders="all">
<Table.Header>
<Table.Row>
<Table.Head>Name</Table.Head>
<Table.Head>Role</Table.Head>
<Table.Head>Department</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>John Doe</Table.Cell>
<Table.Cell>Developer</Table.Cell>
<Table.Cell>Engineering</Table.Cell>
</Table.Row>
</Table.Body>
</Table.Root>
Table Component Props Extends <table> HTMLElement
Prop Type Default Description
headers object Column and row headers configuration
body array[][] Table data in 2D array format
caption object Optional caption with positioning
footer boolean | array[][] Footer rows configuration
colorKey array Color legend configuration
striped boolean false Enable striped rows
borders "none" | "horizontal" | "vertical" | "all" all Border style
textAlign "top" | "bottom" | "center" center Cell content alignment
Component Props Description
Table.Root striped, borders, textAlign Main table wrapper
Table.Header class Table header section
Table.Body class Table body section
Table.Row cloneable, class Table row
Table.Cell class Table cell
Table.Head class Header cell
Table.Footer class Footer section

The Table component includes built-in methods for dynamic row management:

const table = await Ready(document.querySelector<TableElement>('table-wrapper'));
// Add new row
table.appendRow(['John Doe', 'Developer', 'Engineering']);
// Remove specific row
table.removeRow(1);
// Clear all rows
table.clearRows();
---
import { Table } from '@/components/NST-components/UI/table/TableParts.astro';
const data = [ { id: 'INV001', status: 'Paid', method: 'Credit Card', amount: '$250.00' }, { id: 'INV002', status: 'Pending', method: 'PayPal', amount: '$150.00' }, { id: 'INV003', status: 'Paid', method: 'Bank Transfer', amount: '$350.00' } ];
---
<Table.Root striped borders="all" textAlign="center">
<Table.Header>
<Table.Row>
<Table.Head>Invoice</Table.Head>
<Table.Head>Status</Table.Head>
<Table.Head>Method</Table.Head>
<Table.Head>Amount</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
{data.map((row) => (
<Table.Row>
<Table.Cell>{row.id}</Table.Cell>
<Table.Cell>{row.status}</Table.Cell>
<Table.Cell>{row.method}</Table.Cell>
<Table.Cell>{row.amount}</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table.Root>
Performance Metrics
Target Impact
FCP < 2s
TTI < 3.5s Critical
CLS < 0.1 Medium
Performance Metrics
Target Impact
FCP < 2s
TTI < 3.5s Critical
CLS < 0.1 Medium
Result Good

Limited Time Launch Sale

Build better data displays with our AstroJS starter template. Get the Table component and many more UI components ready to use in your next project.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes