| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableBasic = () => {
  return (
    <Table.Root size="sm">
      <Table.Header>
        <Table.Row>
          <Table.ColumnHeader>Product</Table.ColumnHeader>
          <Table.ColumnHeader>Category</Table.ColumnHeader>
          <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {items.map((item) => (
          <Table.Row key={item.id}>
            <Table.Cell>{item.name}</Table.Cell>
            <Table.Cell>{item.category}</Table.Cell>
            <Table.Cell textAlign="end">{item.price}</Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
import { Table } from '@saas-ui/react/table'<Table.Root>
  <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>Use the size prop to change the size of the table.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { For, Stack, Table } from "@chakra-ui/react"
export const TableWithSizes = () => {
  return (
    <Stack gap="10">
      <For each={["sm", "md", "lg"]}>
        {(size) => (
          <Table.Root key={size} size={size}>
            <Table.Header>
              <Table.Row>
                <Table.ColumnHeader>Product</Table.ColumnHeader>
                <Table.ColumnHeader>Category</Table.ColumnHeader>
                <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
              </Table.Row>
            </Table.Header>
            <Table.Body>
              {items.map((item) => (
                <Table.Row key={item.id}>
                  <Table.Cell>{item.name}</Table.Cell>
                  <Table.Cell>{item.category}</Table.Cell>
                  <Table.Cell textAlign="end">{item.price}</Table.Cell>
                </Table.Row>
              ))}
            </Table.Body>
          </Table.Root>
        )}
      </For>
    </Stack>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Use the variant prop to change the appearance of the table.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { For, Stack, Table } from "@chakra-ui/react"
export const TableWithVariants = () => {
  return (
    <Stack gap="10">
      <For each={["line", "outline"]}>
        {(variant) => (
          <Table.Root key={variant} size="sm" variant={variant}>
            <Table.Header>
              <Table.Row>
                <Table.ColumnHeader>Product</Table.ColumnHeader>
                <Table.ColumnHeader>Category</Table.ColumnHeader>
                <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
              </Table.Row>
            </Table.Header>
            <Table.Body>
              {items.map((item) => (
                <Table.Row key={item.id}>
                  <Table.Cell>{item.name}</Table.Cell>
                  <Table.Cell>{item.category}</Table.Cell>
                  <Table.Cell textAlign="end">{item.price}</Table.Cell>
                </Table.Row>
              ))}
            </Table.Body>
          </Table.Root>
        )}
      </For>
    </Stack>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Use the striped prop to add zebra-stripes to the table.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableWithStriped = () => {
  return (
    <Table.Root size="sm" striped>
      <Table.Header>
        <Table.Row>
          <Table.ColumnHeader>Product</Table.ColumnHeader>
          <Table.ColumnHeader>Category</Table.ColumnHeader>
          <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {items.map((item) => (
          <Table.Row key={item.id}>
            <Table.Cell>{item.name}</Table.Cell>
            <Table.Cell>{item.category}</Table.Cell>
            <Table.Cell textAlign="end">{item.price}</Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Use the showColumnBorder prop to add borders between columns.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableWithColumnBorder = () => {
  return (
    <Table.Root size="sm" showColumnBorder>
      <Table.Header>
        <Table.Row>
          <Table.ColumnHeader>Product</Table.ColumnHeader>
          <Table.ColumnHeader>Category</Table.ColumnHeader>
          <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {items.map((item) => (
          <Table.Row key={item.id}>
            <Table.Cell>{item.name}</Table.Cell>
            <Table.Cell>{item.category}</Table.Cell>
            <Table.Cell textAlign="end">{item.price}</Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Render the Table.ScrollArea component to enable horizontal scrolling.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableWithOverflow = () => {
  return (
    <Table.ScrollArea borderWidth="1px" maxW="xl">
      <Table.Root size="sm" variant="outline">
        <Table.Header>
          <Table.Row>
            <Table.ColumnHeader minW="400px">Product</Table.ColumnHeader>
            <Table.ColumnHeader minW="400px">Category</Table.ColumnHeader>
            <Table.ColumnHeader minW="200px" textAlign="end">
              Price
            </Table.ColumnHeader>
          </Table.Row>
        </Table.Header>
        <Table.Body>
          {items.map((item) => (
            <Table.Row key={item.id}>
              <Table.Cell>{item.name}</Table.Cell>
              <Table.Cell>{item.category}</Table.Cell>
              <Table.Cell textAlign="end">{item.price}</Table.Cell>
            </Table.Row>
          ))}
        </Table.Body>
      </Table.Root>
    </Table.ScrollArea>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Use the stickyHeader prop to make the table header sticky.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableWithStickyHeader = () => {
  return (
    <Table.ScrollArea borderWidth="1px" rounded="md" height="160px">
      <Table.Root size="sm" stickyHeader>
        <Table.Header>
          <Table.Row bg="bg.subtle">
            <Table.ColumnHeader>Product</Table.ColumnHeader>
            <Table.ColumnHeader>Category</Table.ColumnHeader>
            <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
          </Table.Row>
        </Table.Header>
        <Table.Body>
          {items.map((item) => (
            <Table.Row key={item.id}>
              <Table.Cell>{item.name}</Table.Cell>
              <Table.Cell>{item.category}</Table.Cell>
              <Table.Cell textAlign="end">{item.price}</Table.Cell>
            </Table.Row>
          ))}
        </Table.Body>
      </Table.Root>
    </Table.ScrollArea>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Use the interactive prop to highlight rows on hover.
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableWithInteractive = () => {
  return (
    <Table.Root size="sm" interactive>
      <Table.Header>
        <Table.Row>
          <Table.ColumnHeader>Product</Table.ColumnHeader>
          <Table.ColumnHeader>Category</Table.ColumnHeader>
          <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {items.map((item) => (
          <Table.Row key={item.id}>
            <Table.Cell>{item.name}</Table.Cell>
            <Table.Cell>{item.category}</Table.Cell>
            <Table.Cell textAlign="end">{item.price}</Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
Here's an example of how to compose a table with pagination.
Products
| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
'use client'
import { HStack, Heading, Stack } from '@chakra-ui/react'
import { Pagination, Table } from '@saas-ui/react'
export const TableWithPagination = () => {
  return (
    <Stack width="full" gap="5">
      <Heading size="xl">Products</Heading>
      <Table.Root size="sm" variant="outline" striped>
        <Table.Header>
          <Table.Row>
            <Table.ColumnHeader>Product</Table.ColumnHeader>
            <Table.ColumnHeader>Category</Table.ColumnHeader>
            <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
          </Table.Row>
        </Table.Header>
        <Table.Body>
          {items.map((item) => (
            <Table.Row key={item.id}>
              <Table.Cell>{item.name}</Table.Cell>
              <Table.Cell>{item.category}</Table.Cell>
              <Table.Cell textAlign="end">{item.price}</Table.Cell>
            </Table.Row>
          ))}
        </Table.Body>
      </Table.Root>
      <Pagination.Root count={items.length * 5} pageSize={5} page={1}>
        <HStack wrap="wrap">
          <Pagination.PrevTrigger />
          <Pagination.Items />
          <Pagination.NextTrigger />
        </HStack>
      </Pagination.Root>
    </Stack>
  )
}
const items = [
  { id: 1, name: 'Laptop', category: 'Electronics', price: 999.99 },
  { id: 2, name: 'Coffee Maker', category: 'Home Appliances', price: 49.99 },
  { id: 3, name: 'Desk Chair', category: 'Furniture', price: 150.0 },
  { id: 4, name: 'Smartphone', category: 'Electronics', price: 799.99 },
  { id: 5, name: 'Headphones', category: 'Accessories', price: 199.99 },
]
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 | |
|---|---|---|---|
| Laptop | Electronics | $999.99 | |
| Coffee Maker | Home Appliances | $49.99 | |
| Desk Chair | Furniture | $150 | |
| Smartphone | Electronics | $799.99 | |
| Headphones | Accessories | $199.99 | 
'use client'
import { useState } from 'react'
import { Kbd, Table } from '@chakra-ui/react'
import { ActionBar, Button, Checkbox } from '@saas-ui/react'
export const TableWithSelectionActionBar = () => {
  const [selection, setSelection] = useState<string[]>([])
  const hasSelection = selection.length > 0
  const indeterminate = hasSelection && selection.length < items.length
  const rows = items.map((item) => (
    <Table.Row
      key={item.name}
      data-selected={selection.includes(item.name) ? '' : undefined}
    >
      <Table.Cell>
        <Checkbox
          top="1"
          aria-label="Select row"
          checked={selection.includes(item.name)}
          onCheckedChange={(changes) => {
            setSelection((prev) =>
              changes.checked
                ? [...prev, item.name]
                : selection.filter((name) => name !== item.name),
            )
          }}
        />
      </Table.Cell>
      <Table.Cell>{item.name}</Table.Cell>
      <Table.Cell>{item.category}</Table.Cell>
      <Table.Cell>${item.price}</Table.Cell>
    </Table.Row>
  ))
  return (
    <>
      <Table.Root>
        <Table.Header>
          <Table.Row>
            <Table.ColumnHeader w="6">
              <Checkbox
                top="1"
                aria-label="Select all rows"
                checked={indeterminate ? 'indeterminate' : selection.length > 0}
                onCheckedChange={(changes) => {
                  setSelection(
                    changes.checked ? items.map((item) => item.name) : [],
                  )
                }}
              />
            </Table.ColumnHeader>
            <Table.ColumnHeader>Product</Table.ColumnHeader>
            <Table.ColumnHeader>Category</Table.ColumnHeader>
            <Table.ColumnHeader>Price</Table.ColumnHeader>
          </Table.Row>
        </Table.Header>
        <Table.Body>{rows}</Table.Body>
      </Table.Root>
      <ActionBar.Root open={hasSelection}>
        <ActionBar.Content>
          <ActionBar.SelectionTrigger>
            {selection.length} selected
          </ActionBar.SelectionTrigger>
          <ActionBar.Separator />
          <Button variant="outline" size="sm">
            Delete <Kbd>⌫</Kbd>
          </Button>
          <Button variant="outline" size="sm">
            Share <Kbd>T</Kbd>
          </Button>
        </ActionBar.Content>
      </ActionBar.Root>
    </>
  )
}
const items = [
  { id: 1, name: 'Laptop', category: 'Electronics', price: 999.99 },
  { id: 2, name: 'Coffee Maker', category: 'Home Appliances', price: 49.99 },
  { id: 3, name: 'Desk Chair', category: 'Furniture', price: 150.0 },
  { id: 4, name: 'Smartphone', category: 'Electronics', price: 799.99 },
  { id: 5, name: 'Headphones', category: 'Accessories', price: 199.99 },
]
Use the Table.ColumnGroup component to distribute the column widths using the
html colgroup element.
htmlWidth| Product | Category | Price | 
|---|---|---|
| Laptop | Electronics | 999.99 | 
| Coffee Maker | Home Appliances | 49.99 | 
| Desk Chair | Furniture | 150 | 
| Smartphone | Electronics | 799.99 | 
| Headphones | Accessories | 199.99 | 
import { Table } from "@chakra-ui/react"
export const TableWithColumnGroup = () => {
  return (
    <Table.Root size="sm" variant="outline">
      <Table.ColumnGroup>
        <Table.Column htmlWidth="50%" />
        <Table.Column htmlWidth="40%" />
        <Table.Column />
      </Table.ColumnGroup>
      <Table.Header>
        <Table.Row>
          <Table.ColumnHeader>Product</Table.ColumnHeader>
          <Table.ColumnHeader>Category</Table.ColumnHeader>
          <Table.ColumnHeader textAlign="end">Price</Table.ColumnHeader>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {items.map((item) => (
          <Table.Row key={item.id}>
            <Table.Cell>{item.name}</Table.Cell>
            <Table.Cell>{item.category}</Table.Cell>
            <Table.Cell textAlign="end">{item.price}</Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  )
}
const items = [
  { id: 1, name: "Laptop", category: "Electronics", price: 999.99 },
  { id: 2, name: "Coffee Maker", category: "Home Appliances", price: 49.99 },
  { id: 3, name: "Desk Chair", category: "Furniture", price: 150.0 },
  { id: 4, name: "Smartphone", category: "Electronics", price: 799.99 },
  { id: 5, name: "Headphones", category: "Accessories", price: 199.99 },
]
| Prop | Default | Type | 
|---|---|---|
| colorPalette  | 'gray' | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | 'accent'The color palette of the component | 
| variant  | 'line' | 'line' | 'outline'The variant of the component | 
| size  | 'md' | 'sm' | 'md' | 'lg'The size of the component | 
| interactive  | 'true' | 'false'The interactive of the component | |
| stickyHeader  | 'true' | 'false'The stickyHeader of the component | |
| striped  | 'true' | 'false'The striped of the component | |
| showColumnBorder  | 'true' | 'false'The showColumnBorder of the component | |
| native  | booleanIf `true`, the table will style its descendants with nested selectors | |
| as  | React.ElementTypeThe underlying element to render. | |
| asChild  | booleanUse the provided child element as the default rendered element, combining their props and behavior.For more details, read our Composition guide. | |
| unstyled  | booleanWhether to remove the component's style. |