Table

Table gives dense records a scannable grid you compose from styled row and cell primitives.

MemberRoleStatus
Aria Patel
Aria Patel
aria@acme.io
OwnerActive
Diego Ramos
Diego Ramos
diego@acme.io
AdminActive
Mei Lin
Mei Lin
mei@acme.io
EditorInvited
Sam Turner
Sam Turner
sam@acme.io
ViewerActive
import Table from '@/components/ui/table';
import Avatar from '@/components/ui/avatar';
import Tag from '@/components/ui/tag';

Installation

Add this component with the NateUI CLI.

npx @nateui/cli@latest add Table

Examples

Basic

import Table from '@/components/ui/table';

const { THead, TBody, Tr, Th, Td } = Table;

Compact

import Table from '@/components/ui/table';

const { THead, TBody, Tr, Th, Td } = Table;

Bordered

import Table from '@/components/ui/table';

const { THead, TBody, Tr, Th, Td } = Table;

Vertical Divider

import Table from '@/components/ui/table';

const { THead, TBody, Tr, Th, Td } = Table;

Grouped Header

import Table from '@/components/ui/table';

const { THead, TBody, Tr, Th, Td } = Table;

Sorting

import { useState } from 'react';
import Table from '@/components/ui/table';

const { THead, TBody, Tr, Th, Td, Sorter } = Table;

Filtering

import { useState } from 'react';
import Table from '@/components/ui/table';
import Input from '@/components/ui/input';

Row Selection

import { useState } from 'react';
import Table from '@/components/ui/table';
import Checkbox from '@/components/ui/checkbox';

Pagination

import { useState } from 'react';
import Table from '@/components/ui/table';
import Pagination from '@/components/ui/pagination';

Expandable Rows

import { Fragment, useState } from 'react';
import Table from '@/components/ui/table';
import { PiCaretRight } from 'react-icons/pi'

TanStack Table

import { useMemo, useState } from 'react';
import {
  columnVisibilityFeature,
  createPaginatedRowModel,

API

Table is a compound component: the default export is the styling wrapper, and the section, row, and cell primitives hang off it as Table.THead, Table.TBody, Table.TFoot, Table.Tr, Table.Th, Table.Td, and Table.Sorter. Each primitive renders its matching native element and forwards native props, so you own the data and behavior yourself.

Table

PropDescriptionTypeDefault
borderedWrap the table or overflow renderer in a bordered card surface.booleanfalse
compactReduce cell padding for dense data.booleanfalse
hoverableHighlight body rows on hover.booleantrue
overflowWrap the table in an overflow container. Uses the native overflow wrapper unless renderOverflow is supplied.booleantrue
overflowClassExtra classes for the default overflow container.string-
renderOverflowRenders a custom overflow container around the table when overflow is enabled. The result is placed inside the bordered surface when bordered is enabled.(table: ReactNode) => ReactNode-
verticalDividerShow vertical column dividers per section.TableVerticalDivider{ head: false, body: false, footer: false }
asElementRender the table as a different element, for example a flex layout.ElementType'table'
...nativePropsNative table element props.ComponentPropsWithRef<'table'>-

Table.THead / Table.TBody / Table.TFoot

PropDescriptionTypeDefault
asElementRender the section as a different element.ElementType'thead' / 'tbody' / 'tfoot'
...nativePropsNative section element props.ComponentPropsWithRef<'thead'>-

Table.Tr

PropDescriptionTypeDefault
asElementRender the row as a different element.ElementType'tr'
...nativePropsNative tr props, including className for selected or active rows.ComponentPropsWithRef<'tr'>-

Table.Th / Table.Td

PropDescriptionTypeDefault
asElementRender the cell as a different element.ElementType'th' / 'td'
...nativePropsNative cell props, including colSpan, rowSpan, and className.ComponentPropsWithRef<'th'>-

Table.Sorter

PropDescriptionTypeDefault
sortCurrent sort direction. true shows the neutral indicator; 'asc' and 'desc' show the active arrows.boolean | 'asc' | 'desc'-
classNameExtra classes for the sorter wrapper.string-

Types

type TableVerticalDivider = {
  head?: boolean
  body?: boolean
  footer?: boolean
}