Table

Used to display data in a tabular format.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Usage

import { Table } from "chakra-ui-solid";
<Table.Root>
  <Table.Caption />
  <Table.Header>
    <Table.Row>
      <Table.ColumnHeader />
    </Table.Row>
  </Table.Header>
  <Table.Body>
    <Table.Row>
      <Table.Cell />
    </Table.Row>
  </Table.Body>
  <Table.Footer>
    <Table.Row>
      <Table.Cell />
    </Table.Row>
  </Table.Footer>
</Table.Root>

Examples

Sizes

Use the size prop to change the size of the table.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Variants

Use the variant prop to change the appearance of the table.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Striped

Use the striped prop to add zebra-stripes to the table.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Caption

Use the Table.Caption component to add a caption to the table.

Product inventory and pricing information
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Caption Top

Use the captionSide prop on Table.Caption to position the caption at the top of the table.

Product inventory and pricing information
ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Column Border

Use the showColumnBorder prop to add borders between columns.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Overflow

Render the Table.ScrollArea component to enable horizontal scrolling.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Use the stickyHeader prop to make the table header sticky.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Sticky Column

Here’s an example what uses data-sticky attributes to make table columns sticky during horizontal scrolling.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Sticky Header and Column

Combine stickyHeader with data-sticky attributes to create a table with both a sticky header and sticky columns. When using both features together, ensure the header row has a higher z-index to keep sticky column headers visible.

ProductCategoryPrice
HeadphonesElectronics834.12
Desk ChairFurniture245.88
MicrowaveHome Appliances379.26
BackpackAccessories112.47
FootballSports95.14
SmartphoneElectronics921.63
Wrist WatchAccessories418.52
T-ShirtClothing35.29
Vacuum CleanerHome Appliances601.22
LampFurniture157.88
DroneElectronics836.15
PerfumeBeauty128.9
Camping TentOutdoors458.4

Highlight on Hover

Use the interactive prop to highlight rows on hover.

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Column Group

Use the Table.ColumnGroup component to distribute the column widths using the html colgroup element.

The only prop that works for this component is htmlWidth

ProductCategoryPrice
LaptopElectronics999.99
Coffee MakerHome Appliances49.99
Desk ChairFurniture150
SmartphoneElectronics799.99
HeadphonesAccessories199.99

Native Mode

There is no native prop here, where the React version has one for rendering <thead>, <tbody>, <tr>, <td> and <th> directly inside Table.Root.

It works there by taking each slot’s resolved style object and re-hanging it on & thead, & tr, & td — a composition that happens while the component renders. A slot here resolves to a class name instead, and the rules behind it are generated by your Panda build long before anything renders, so there is nothing to compose.

What the prop buys upstream is stated on their page as performance: “eliminating the runtime styling and React Context overhead”. Neither cost is here to remove. Table.Row and Table.Cell compute no styles at render time, and reading the Root’s class map costs one context read that never invalidates. Write the part components.

Props

Root

TableRootProps
PropDefaultType
interactive—
ConditionalValue<boolean>

Highlight a body row on hover, for a table whose rows are clickable.

showColumnBorder—
ConditionalValue<boolean>

Draw a rule between columns as well as between rows.

size'md'
ConditionalValue<'sm' | 'md' | 'lg' | PresetVariant<'table', 'size'>>

The cell padding and the table's type scale.

stickyHeader—
ConditionalValue<boolean>

Pin the header row while the body scrolls under it. It only does anything inside a {@link TableScrollArea} — that is the box with the scrollbar — and offsets from `--table-sticky-offset`.

striped—
ConditionalValue<boolean>

Zebra-stripe the body: every odd row's cells take `bg.muted`.

variant'line'
ConditionalValue<'line' | 'outline' | PresetVariant<'table', 'variant'>>

`line` rules each row off; `outline` boxes the whole table and tints the header.

Plus HTMLChakraProps<"table"> — the whole style-prop surface and the DOM attributes of the element it renders, several hundred names listed as their sources rather than expanded — and the three every component takes: as, render and unstyled.