Skip to contentSkip to navigationSkip to topbar
Paste assistant Assistant
Figma
Star

Data Grid

Version 8.3.1GithubStorybookPeer review pending

A data grid is an interactive table used for working with a large collection of data in a scannable way.

Installation

Installation page anchor
yarn add @twilio-paste/data-grid - or - yarn add @twilio-paste/core
import {
  DataGrid,
  DataGridHead,
  DataGridRow,
  DataGridHeader,
  DataGridBody,
  DataGridCell,
  DataGridFoot,
} from '@twilio-paste/core/data-grid';

const Component = () => (
  <DataGrid aria-label="User information table" striped>
    <DataGridHead>
      <DataGridRow>
        <DataGridHeader>First Name</DataGridHeader>
        <DataGridHeader>Last Name</DataGridHeader>
        <DataGridHeader>Country</DataGridHeader>
        <DataGridHeader>Email</DataGridHeader>
        <DataGridHeader>Phone</DataGridHeader>
      </DataGridRow>
    </DataGridHead>
    <DataGridBody>
      <DataGridRow>
        <DataGridCell>Devyn</DataGridCell>
        <DataGridCell>Weimann</DataGridCell>
        <DataGridCell>Congo</DataGridCell>
        <DataGridCell>Matilde86@gmail.com</DataGridCell>
        <DataGridCell>652-441-1766 x377</DataGridCell>
      </DataGridRow>
      <DataGridRow>
        <DataGridCell>Fritz</DataGridCell>
        <DataGridCell>Bashirian</DataGridCell>
        <DataGridCell>France</DataGridCell>
        <DataGridCell>Magali.Harber@hotmail.com</DataGridCell>
        <DataGridCell>1-229-278-7567</DataGridCell>
      </DataGridRow>
      <DataGridRow>
        <DataGridCell>Jovanny</DataGridCell>
        <DataGridCell>Mante</DataGridCell>
        <DataGridCell>Pitcairn Islands</DataGridCell>
        <DataGridCell>Fausto_Vandervort15@gmail.com</DataGridCell>
        <DataGridCell>(629) 375-5743 x726</DataGridCell>
      </DataGridRow>
    </DataGridBody>
    <DataGridFoot>
      <DataGridRow>
        <DataGridCell>Devyn</DataGridCell>
        <DataGridCell>Weimann</DataGridCell>
        <DataGridCell>Congo</DataGridCell>
        <DataGridCell>Matilde86@gmail.com</DataGridCell>
        <DataGridCell>652-441-1766 x377</DataGridCell>
      </DataGridRow>
    </DataGridFoot>
  </DataGrid>
);

DataGrid

DataGrid page anchor

aria-label RequiredRequired

Type
string

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'DATA_GRID'

role

If creating a treegrid, set this to "treegrid" to override the default role of "grid"

Type
"treegrid"
Default
grid

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
string
Default
'DATA_GRID_HEAD'

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'DATA_GRID_ROW'

role

Type
string

selected

Visally displays a row highlight indicating selection and sets aria-selected

Type
boolean

striped

Type
boolean

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'DATA_GRID_HEADER'

onClick

Type
MouseEventHandler<Element>

direction RequiredRequired

Sort direction matching aria spec

Type
SortDirection

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'DATA_GRID_HEADER_SORT'

i18nAscendingLabel

Sort button label text when direction is "ascending"

Type
string
Default
'Sort ascending'

i18nDescendingLabel

Sort button label text when direction is "descending"

Type
string
Default
'Sort descending'

i18nUnsortedLabel

Sort button label text when direction is "none"

Type
string
Default
'Unsorted'

onClick

Callback when the sort button is pressed. Used to handle sorting.

Type
() => void

tabIndex

Type
any

as

Type
"th" | "td"

colSpan

How many columns the cell spans across

Type
number

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'DATA_GRID_CELL'

onClick

Type
MouseEventHandler<Element>

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'DATA_GRID_FOOT'