shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Table

A responsive table component.

A list of your recent invoices.
Invoice Status Method Amount
INV001 Paid Credit Card $250.00
INV002 Pending PayPal $150.00
INV003 Unpaid Bank Transfer $350.00
INV004 Paid Credit Card $450.00
INV005 Paid PayPal $550.00
INV006 Pending Bank Transfer $200.00
INV007 Unpaid Credit Card $300.00
Total $2,500.00
package examples import "github.com/axadrn/shadcn-templ/v2/components/table"

Installation

shadcn-templ add table

Usage

import "github.com/axadrn/shadcn-templ/v2/components/table"
@table.Table() {	@table.Caption() {		A list of your recent invoices.	}	@table.Header() {		@table.Row() {			@table.Head(table.HeadProps{Class: "w-[100px]"}) {				Invoice			}			@table.Head() {				Status			}			@table.Head() {				Method			}			@table.Head(table.HeadProps{Class: "text-right"}) {				Amount			}		}	}	@table.Body() {		@table.Row() {			@table.Cell(table.CellProps{Class: "font-medium"}) {				INV001			}			@table.Cell() {				Paid			}			@table.Cell() {				Credit Card			}			@table.Cell(table.CellProps{Class: "text-right"}) {				$250.00			}		}	}}

Composition

Use the following composition to build a Table:

table.Table├── table.Caption├── table.Header│   └── table.Row│       ├── table.Head│       ├── table.Head│       ├── table.Head│       └── table.Head├── table.Body│   ├── table.Row│   │   ├── table.Cell│   │   ├── table.Cell│   │   ├── table.Cell│   │   └── table.Cell│   └── table.Row│       ├── table.Cell│       ├── table.Cell│       ├── table.Cell│       └── table.Cell└── table.Footer

Use the table.Footer component to add a footer to the table.

A list of your recent invoices.
Invoice Status Method Amount
INV001 Paid Credit Card $250.00
INV002 Pending PayPal $150.00
INV003 Unpaid Bank Transfer $350.00
Total $2,500.00
package examples import "github.com/axadrn/shadcn-templ/v2/components/table"

Actions

A table showing actions for each row using a DropdownMenu component.

Product Price Actions
Wireless Mouse $29.99
Mechanical Keyboard $129.99
USB-C Hub $49.99
package examples import (

API Reference

Table

The table.Table component renders a native table inside a scrollable container.

Prop Type Default
Class string -

TableHeader, TableBody, TableFooter

The table.Header, table.Body and table.Footer components render the table sections.

Prop Type Default
Class string -

TableRow, TableHead, TableCell, TableCaption

The table.Row, table.Head, table.Cell and table.Caption components render rows, header cells, data cells and the caption.

Prop Type Default
Class string -