Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Table

Displays tabular data. Supports row selection and striped rows.

View in Storybook (opens in a new tab)

Installation

import { Table } from "@ginga-ui/core";

Basic usage

A simple table example.

NameTypeModifiedSize
DocumentsFolderDec 1, 20241.2 GB
ImagesFolderNov 28, 2024894 MB
README.mdMarkdown fileDec 15, 20244 KB
package.jsonJSON fileDec 10, 20242 KB
table.tsx
import { Table } from "@ginga-ui/core";

export function BasicExample() {
  return <Table data={sampleData} columns={columns} aria-label="File list" />;
}

Striped

Specify striped to add a background color to even rows, making rows easier to follow.

NameTypeModifiedSize
DocumentsFolderDec 1, 20241.2 GB
ImagesFolderNov 28, 2024894 MB
README.mdMarkdown fileDec 15, 20244 KB
package.jsonJSON fileDec 10, 20242 KB
table.tsx
import { Table } from "@ginga-ui/core";

export function StripedExample() {
  return (
    <Table
      data={sampleData}
      columns={columns}
      striped
      aria-label="Striped file list"
    />
  );
}

Row selection

A table with selectable rows.

NameTypeModifiedSize
DocumentsFolderDec 1, 20241.2 GB
ImagesFolderNov 28, 2024894 MB
README.mdMarkdown fileDec 15, 20244 KB
package.jsonJSON fileDec 10, 20242 KB
table.tsx
import { Table } from "@ginga-ui/core";

export function WithSelectionExample() {
  return (
    <Table
      data={sampleData}
      columns={columns}
      selectionMode="multiple"
      aria-label="Selectable file list"
      onSelectionChange={(keys) => console.log("Selected:", keys)}
    />
  );
}

User table

A practical example of a user data table.

NameEmail addressRole
John Smithjohn@example.comAdmin
Emily Johnsonemily@example.comEditor
Michael Brownmichael@example.comViewer
table.tsx
import { Table } from "@ginga-ui/core";

export function UserTableExample() {
  return <Table data={userData} columns={userColumns} aria-label="User list" />;
}

Empty state

Use emptyMessage to set the message shown when there is no data.

NameTypeModifiedSize
No files yet
table.tsx
import { Table } from "@ginga-ui/core";

export function EmptyStateExample() {
  return (
    <Table
      data={[]}
      columns={columns}
      emptyMessage="No files yet"
      aria-label="Empty table"
    />
  );
}

Props

Table

children cannot be passed. Pass rows with data and columns with columns.

NameTypeDefaultDescription
dataT[]-Required. Rows to display.
columnsTableColumn<T>[]-Required. Column definitions. See TableColumn below.
aria-labelstring-Required. Accessible name of the table.
getRowKey(row: T, index: number) => Key-Returns the key of a row. When omitted, the row's id is used, or the index if there is no id.
selectionMode"none" | "single" | "multiple""none"Row selection mode. A checkbox column is added when rows can be selected.
onSelectionChange(selectedRows: T[], keys: Selection) => void-Called with the selected rows and their keys when the selection changes.
showHeaderbooleantrueShows the header row. When false, it is hidden visually but still read by screen readers.
stripedbooleanfalseAlternates the background color of rows.
emptyMessageReactNode-Content shown when data is empty.

Also accepts the props of React Aria's Table (opens in a new tab).

TableColumn<T>

NameTypeDefaultDescription
keystring-Required. Unique key of the column.
headerReactNode-Required. Header content.
accessorkeyof T | ((row: T) => ReactNode)-Required. Property name of the row to show, or a function that returns the cell content.
isRowHeaderboolean-Uses this column as the row header. When no column sets it, the first column is used.
allowsSortingboolean-Makes the column sortable. Handle sorting with sortDescriptor and onSortChange.