DataTable

a data driven table

Name
Complete
Alan
Bryan
Chris
Eric

Props

a11yTitle

Custom label to be used by screen readers. When provided, an aria-label will be added to the element.

"a user friendly label for screen readers"

alignSelf

How to align along the cross axis when contained in a Box or along the column axis when contained in a Grid.

"start"
"center"
"end"
"stretch"

background

Cell background. You can set the background per context by passing an object with keys for 'heading', 'body', and/or 'footer'. If you pass an array, rows will cycle between the array values.

"light-2"
["white", "light-2"]
{
  "header": "dark-2",
  "body": ["white", "light-2"],
  "footer": "dark-3"
}

border

Cell border. You can set the border per context by passing an object with keys for 'heading', 'body', and/or 'footer'.

true
"horizontal"
"vertical"
"top"
"bottom"
"right"
"left"
{
  "color": "border",
  "side": "horizontal",
  "size": "small"
}
{
  "header": "bottom",
  "body": {
    "color": "light-2",
    "side": "bottom"
  },
  "footer": "top"
}

columns

A description of the data. The order controls the column order. 'property' indicates which property in the data objects to associate the column with. 'header' indicates what to display in the column header. 'render' allows for custom rendering of body cells. Use 'render' for custom formatting for things like currency and date or to display rich content like Meters. 'align' indicates how the cells in the column are aligned. 'aggregate' indicates how the data in the column should be aggregated. This only applies to a footer or groupBy context. 'footer' indicates what should be shown in the footer for the column. 'search' indicates whether a search filter should be made available for the column. 'primary' indicates that this property should be used as the unique identifier, which gives the cell 'row' scope for accessibility. If 'primary' is not used for any column, and 'primaryKey' isn't specified either, then the first column will be used. 'pin' indicates that this column should not scroll out of view to the left when the table is scrolled horizontally.

[
  {
    "align": "center",
    "aggregate": "avg",
    "footer": {"aggregate": true},
    "header": "Name",
    "primary": true,
    "property": "name",
    "render": "(datum) => <Content />",
    "size": "small",
    "search": true,
    "sortable": true
  }
]
where align could be:"start""center""end"
where aggregate could be:"avg""max""min""sum"

data

Array of data objects.
{
""
}

fill

Whether the width and/or height should fill the container.
"horizontal""vertical"truefalse

gridArea

The name of the area to place this inside a parent Grid.

"a parent grid area name"

groupBy

Property to group data by. If object is specified 'property' is used to group data by, 'expand' accepts array of group keys that sets expanded groups and 'onExpand' is a function that will be called after expand button is clicked with an array of keys of expanded groups.

"location"
{
  "property": "location",
  "expand": ["Paris", "Los Angeles"],
  "onExpand": "(key) => {...}"
}

margin

The amount of margin around the component. An object can be specified to distinguish horizontal margin, vertical margin, and margin on a particular side.

"xsmall"
"small"
"medium"
"large"
"xlarge"
{
  "vertical": "...",
  "horizontal": "...",
  "top": "...",
  "bottom": "...",
  "left": "...",
  "right": "..."
}

onClickRow

When supplied, this function will be called with an event object that include a 'datum' property containing the data value associated with the clicked row. You should not include interactive elements, like Anchor or Button inside table cells as that can cause confusion with overlapping interactive elements.

({ datum }) => {...}

onMore

Use this to indicate that 'data' doesn't contain all that it could. It will be called when all of the data rows have been rendered. This might be used when the total number of items that could be retrieved is more than you'd want to load into the browser. 'onMore' allows you to lazily fetch more from the server only when needed. This cannot be combined with properties that expect all data to be present in the browser, such as columns.search, sortable, groupBy, or columns.aggregate.

() => {...}

onSearch

When supplied, and when at least one column has 'search' enabled, this function will be called with an object with keys for property names and values which are the search text strings. This is typically employed so a back-end can be used to search through the data.

({ key: "search text", ... }) => {...}

onSelect

When supplied, causes checkboxes to be added to each row such that the user can indicate which rows should be selected. This function will be called with an array of primary key values, suitable to be passed to the 'select' property. If you are storing select state via a 'useState' hook, you can do something like: '<DataTable select={select} onSelect={setSelect} />'.

"function"

onSort

When supplied, this function will be called with an object with a 'property' property that indicates which property is being sorted on and a 'direction' property that will either be 'asc' or 'desc'. onSort={({ property, direction }) => {}}

"function"

pad

Cell padding. You can set the padding per context by passing an object with keys for 'heading', 'body', and/or 'footer'.

"xxsmall""xsmall""small""medium""large""xlarge""string"
{
horizontal:
"xxsmall""xsmall""small""medium""large""xlarge""string,"
vertical:
"xxsmall""xsmall""small""medium""large""xlarge""string,"
top:
"xxsmall""xsmall""small""medium""large""xlarge""string,"
bottom:
"xxsmall""xsmall""small""medium""large""xlarge""string,"
left:
"xxsmall""xsmall""small""medium""large""xlarge""string,"
right:
"xxsmall""xsmall""small""medium""large""xlarge""string"
}
{
header:
"custom,"
body:
"custom,"
footer: custom
}

pin

Whether the header and/or footer should be pinned when not all rows are visible. A value of true pins both header and footer.

truefalse"header""footer"

primaryKey

When supplied, indicates the property for a data object to use to get a unique identifier. See also the 'columns.primary' description. Use this property when the columns approach will not work for your data set. Setting primaryKey to false indicates there should be no unique identifier, avoid this as it's less accessible.

"string"truefalse

replace

Whether to replace previously rendered items with a generic spacing element when they have scrolled out of view. This is more performant but means that in-page searching will not find elements that have been replaced.

truefalse

resizeable

Whether to allow the user to resize column widths.
truefalse

rowProps

Row specific background, border, and pad, keyed by primary key value. For example: { "primary-key-value": { background: ..., border: ..., pad: ... }}, where the background, border, and pad accept the same values as the same named properties on DataTable.

{
""
}

select

When supplied, causes checkboxes to be added to each row to indicate which rows are selected. The values in this array should match the 'primaryKey' or 'columns[].primary' keyed value for the row's data object. If 'onSelect' is provided, the CheckBoxes are enabled and this function can be used to track select changes.

[
"string""number"
]

size

The height of the table body. If set, the table body will have a fixed height and the rows will be scrollable within it. In order to preserve header and footer cell alignment, all cells will have the same width. This cannot be used in combination with 'resizeable'.

"small""medium""large""xlarge""string"

sort

Which property to sort on and which direction to sort. When 'external' is true, it indicates that the caller will take care of sorting the 'data' via 'onSort'. Otherwise, the existing data will be sorted within DataTable.

{
direction:
"asc""desc,"
external:
"boolean,"
property: string
}

sortable

Whether to allow the user to sort columns.
truefalse

step

How many items to render at a time.
50

Theme

global.hover.background

The background style when hovering over an interactive row.
{"color": "active", "opacity": "medium"}

global.hover.color

The text color when hovering over an interactive row.
{"dark": "white", "light": "black"}

dataTable.body.extend

Any additional style for an DataTable Body
"any CSS"
(props) => {}

dataTable.groupHeader.background

The background color of the group header.
{"dark": "dark-2", "light": "light-2"}

dataTable.groupHeader.border.side

The border side rendered for the group header.
"bottom"

dataTable.groupHeader.border.size

The border size of the group header border.
"xsmall"

dataTable.groupHeader.fill

Whether the height should fill the group header.
string

dataTable.groupHeader.pad

The pad used for the group header.
{
  "horizontal": "small",
  "vertical": "xsmall"
}

dataTable.header

Styles for the header.
{"gap": "small"}

dataTable.header.background

Any valid Box background value.
string | { dark: string, light: string } | { color: { dark: string, light: string } | string, dark: bool, image: string, position: string, opacity: bool | string, repeat: no-repeat | repeat, size: cover | contain | string }

dataTable.header.border

Any valid Box border value.
string | object

dataTable.header.color

The label and icon color in a header cell.
{ dark: string, light: string } | string

dataTable.header.extend

Any additional styles for header cells.
"any CSS"
(props) => {}

dataTable.header.font.weight

The font weight for text in header cells.
string

dataTable.header.font.size

The font size for text in header cells.
string

dataTable.header.gap

The gap between elements within the header cell.
"small"

dataTable.header.hover.background

The hover background color of the header cell contents, if clickable. Any valid Box background options apply.

string | { dark: string, light: string } | { color: { dark: string, light: string } | string, dark: bool, image: string, position: string, opacity: bool | string, repeat: no-repeat | repeat, size: cover | contain | string }

dataTable.header.pad

The pad around the contents of the header cell.
string | object

dataTable.resize.hover.color

The color of the resizer when hovered over.
string | object

dataTable.resize.hover.side

The side of the resizer when hovered over. If color or size are defined, this will default to 'end' which is the recommended value.

string

dataTable.resize.hover.size

The size of the resizer when hovered over. Size values correspond with those accepted by Box border.

string

dataTable.icons.ascending

The ascending icon.

dataTable.icons.contract

The contract icon.

dataTable.icons.descending

The descending icon.

dataTable.icons.expand

The expand icon.

dataTable.icons.sortable

The icon indicating a column can be sorted.
React.Element

dataTable.pinned.body.background

Any valid Box background options apply.
string | { dark: string, light: string } | { color: { dark: string, light: string } | string, dark: bool, image: string, position: string, opacity: bool | string, repeat: no-repeat | repeat, size: cover | contain | string }

dataTable.pinned.body.extend

Any additional styles for pinned body cells.
"any CSS"
(props) => {}

dataTable.pinned.header.background

Any valid Box background options apply.
string | { dark: string, light: string } | { color: { dark: string, light: string } | string, dark: bool, image: string, position: string, opacity: bool | string, repeat: no-repeat | repeat, size: cover | contain | string }

dataTable.pinned.header.extend

Any additional styles for pinned header cells.
"any CSS"
(props) => {}

dataTable.pinned.footer.background

Any valid Box background options apply.
string | { dark: string, light: string } | { color: { dark: string, light: string } | string, dark: bool, image: string, position: string, opacity: bool | string, repeat: no-repeat | repeat, size: cover | contain | string }

dataTable.pinned.footer.extend

Any additional styles for pinned footer cells.
"any CSS"
(props) => {}

dataTable.primary.weight

The font weight for primary cells.
"bold"

dataTable.resize.border.color

The border color for resize.
"border"

dataTable.resize.border.side

The border side used for resize.
"end"

table.row.hover.background

The background color when hovering over an interactive row.
string | { color: string, opacity: string }

table.row.hover.color

The text color when hovering over an interactive row.
string | { dark: string, light: string }