Table
Shows data in rows and columns.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Usage
import { Table } from '@leverui/components';
<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.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Variants
Use the variant prop to change the appearance of the table.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Striped
Use the striped prop to add zebra-stripes to the table.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Caption
Use the Table.Caption component to add a caption to the table.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Caption Top
Use the captionSide prop on Table.Caption to position the caption at the top of the table.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Column Border
Use the showColumnBorder prop to add borders between columns.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Overflow
Render the Table.ScrollArea component to enable horizontal scrolling.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Sticky Header
Use the stickyHeader prop to make the table header sticky.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Sticky Column
Here's an example what uses data-sticky attributes to make table columns sticky during horizontal scrolling.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
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.
| Product | Category | Price |
|---|---|---|
| Headphones | Electronics | 834.12 |
| Desk chair | Furniture | 245.88 |
| Microwave | Home appliances | 379.26 |
| Backpack | Accessories | 112.47 |
| Football | Sports | 95.14 |
| Smartphone | Electronics | 921.63 |
| Wrist watch | Accessories | 418.52 |
| T-shirt | Clothing | 35.29 |
| Vacuum cleaner | Home appliances | 601.22 |
| Lamp | Furniture | 157.88 |
| Drone | Electronics | 836.15 |
| Perfume | Beauty | 128.9 |
| Camping tent | Outdoors | 458.4 |
| Cookware set | Home appliances | 292.86 |
| Camera | Electronics | 792.54 |
| Sneakers | Clothing | 154.61 |
| Monitor | Electronics | 348.57 |
| Gaming console | Electronics | 896.01 |
| Keyboard | Electronics | 94.71 |
| Sofa | Furniture | 719.33 |
| Tablet | Electronics | 612.57 |
| Action figure | Toys | 73.49 |
| Smartwatch | Electronics | 482.46 |
| Tent | Outdoors | 623.3 |
| Cookware set | Home appliances | 257.38 |
| Helmet | Sports | 88.26 |
| Hair dryer | Beauty | 164.79 |
| Lamp | Furniture | 122.1 |
| Electric kettle | Home appliances | 69.42 |
| Sneakers | Clothing | 182.13 |
| Drone | Electronics | 934.72 |
| Coffee maker | Home appliances | 148.99 |
| Backpack | Accessories | 81.22 |
| Microwave | Home appliances | 399.53 |
| T-shirt | Clothing | 45.33 |
| Vacuum cleaner | Home appliances | 552.87 |
Highlight on Hover
Use the interactive prop to highlight rows on hover.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Pagination
Here's an example of how to compose a table with pagination.
Products
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Selection
Here's an example of how to add row selection with checkboxes to your table.
| Product | Category | Price | |
|---|---|---|---|
| Monitor | Electronics | $999 | |
| Rice cooker | Kitchen | $64.5 | |
| Bookshelf | Furniture | $135 | |
| Tablet | Electronics | $549 | |
| Backpack | Accessories | $89.95 |
Action Bar
Here's an example of how to compose a table with an action bar and checkboxes. This is useful for showing actions for selected table rows.
| Product | Category | Price | |
|---|---|---|---|
| Monitor | Electronics | $999 | |
| Rice cooker | Kitchen | $64.5 | |
| Bookshelf | Furniture | $135 | |
| Tablet | Electronics | $549 | |
| Backpack | Accessories | $89.95 |
Column Group
Use the Table.ColumnGroup component to distribute the column widths using the html colgroup element.
Set each width with the
htmlWidthprop. Browsers apply only a few CSS properties tocolelements.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | 999 |
| Rice cooker | Kitchen | 64.5 |
| Bookshelf | Furniture | 135 |
| Tablet | Electronics | 549 |
| Backpack | Accessories | 89.95 |
Native Mode
Use the native prop to render table descendants using native HTML elements (<thead>, <tbody>, <tr>, <td>, <th>) instead of Lever UI's styled components.
This is a great way to improve performance for large tables by eliminating the per-part components and Solid context overhead.
| Product | Category | Price |
|---|---|---|
| Monitor | Electronics | $999.00 |
| Rice cooker | Kitchen | $64.50 |
| Bookshelf | Furniture | $135.00 |
| Tablet | Electronics | $549.00 |
| Backpack | Accessories | $89.95 |
TanStack Table
Lever UI works seamlessly with TanStack Table for advanced table features.
| Product | Category | Price | Stock |
|---|---|---|---|
| Monitor | Electronics | $999.00 | 50 |
| Rice cooker | Kitchen | $64.50 | 120 |
| Bookshelf | Furniture | $135.00 | 30 |
| Tablet | Electronics | $549.00 | 75 |
| Backpack | Accessories | $89.95 | 200 |
See the TanStack Table documentation for its Solid adapter.
Props
Root
| Prop | Default | Type | Description |
|---|---|---|---|
colorPalette | gray | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | Color palette. |
variant | line | 'line' | 'outline' | Table style. |
size | md | 'sm' | 'md' | 'lg' | Table size. Responsive. |
native | — | boolean | Style plain HTML table elements inside the root, such as tr and td. |
as | table | Native HTML tag | HTML tag to render. |
asChild | — | Solid render function | Render your own element with the table's props. |
unstyled | false | boolean | Turn off the Lever UI styles. Markup and classes stay. |
interactive | — | boolean | Highlight a row on hover. |
stickyHeader | — | boolean | Keep the header in view while the table scrolls. |
striped | — | boolean | Shade every other row. |
showColumnBorder | — | boolean | Add borders between columns. |
Table renders plain HTML table elements. It adds no keyboard handling,
selection state, or ARIA roles. Use what HTML tables already have, such as
scope on column headers. The root and the parts pass native attributes,
events, refs, class, and style to their elements.
Caption sits below the table by default (captionSide="bottom"). In native
mode a plain caption element stays at the top. To move it down, use
Table.Caption or your own CSS.
Use ColumnGroup and Column for column widths, Footer for totals and
summaries, and ScrollArea when the table is wider than its container.
Table.RootPropsProvider sets reactive default props for the roots inside it.
If the defaults depend on a signal, pass a function that returns them. A prop
on a root wins.
With a headless data grid library, render the headers and rows from its Solid
adapter inside Table.Root native. The TanStack example uses
@tanstack/solid-table. Install that package yourself.
Customize with CSS
Classes: .leverui-table__root, __header, __body, __row,
__columnHeader, __cell, __footer, __caption, __columnGroup,
__column, and __scrollArea. The root also has attributes for size, variant,
stripes, hover, sticky header, column borders, palette, native mode, and
unstyled. Override these, or the --leverui-* tokens, in your own CSS. Add a
part's class to your own HTML element to give it that part's look.
<Table.Root>
<Table.Body>
<Table.Row>
<td class="leverui-table__cell custom-cell">Custom cell</td>
</Table.Row>
</Table.Body>
</Table.Root>
.custom-cell {
text-align: end;
}
Explorer
Click a part name to highlight it in the preview.
Component Anatomy
Hover to highlight, click to select parts