Tonic UI
Getting StartedColor ModeColor StyleVersionsContributing
THEME
BordersBreakpointsColorsOutlinesPositionsSpacingSizesShadowsTypography
BUILDING BLOCKS
BoxControlBox
UTILITIES

Table

Import

  • Table: The wrapper that provides props, state, and context to its children.
  • TableHeader: The header of the table.
  • TableHeaderRow: The header row of the table.
  • TableHeaderCell: The header cell of the table.
  • TableBody: The body of the table.
  • TableRow: The body row of the table.
  • TableCell: The body cell of the table.

Usage

EDITABLE EXAMPLE

Variants

Use the variant prop to change the visual style of the Table. You can set the value to default, outline.

  • default: Only add bottom border into cells, including table header.
  • outline: Adds borders on all sides of the table and cells.
EDITABLE EXAMPLE

Sizes

Use the size prop to change the padding of the <TableCell>. You can set the value to sm, md, or lg.

EDITABLE EXAMPLE

Hoverable

Enable a hover state on TableRows.

EDITABLE EXAMPLE

Custom tables

In the following examples, we demonstrate how to use react-table with the Table component.

import { useTable, useBlockLayout, useRowSelect, useSortBy } from 'react-table';

Base table

EDITABLE EXAMPLE

Selectable table

EDITABLE EXAMPLE

Sortable table

EDITABLE EXAMPLE

Resizable table

EDITABLE EXAMPLE

Scrollable table

EDITABLE EXAMPLE

Full width table

In this example, we use react-virtualized to get full width.

import { AutoSizer } from 'react-virtualized';

EDITABLE EXAMPLE

Row reordering

By react-movable

In this example, we use react-movable to move table rows.

import { List, arrayMove } from 'react-movable';

EDITABLE EXAMPLE

By react-dnd

In this example, we use react-dnd to move table rows.

import { DndProvider, useDrop, useDragLayer } from 'react-dnd';

import { HTML5Backend, getEmptyImage } from 'react-dnd-html5-backend';

import update from 'immutability-helper';

EDITABLE EXAMPLE

Column reordering

In this example, we use react-beautiful-dnd to move table columns.

import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";

EDITABLE EXAMPLE

Props

Table

NameTypeDefaultDescription
sizestring'md'The size of TableCells. One of: 'sm', 'md', 'lg'
variantstring'default'The variant of the table style to use. One of: 'default', 'outline'

TableHeader

TableHeaderRow

TableHeaderCell

NameTypeDefaultDescription
widthstringnumber150

TableBody

TableRow

TableCell

NameTypeDefaultDescription
widthstringnumber150