You are viewing a PR preview for PR #1506

Agriculture Design System
Beta
Design System for the Export Service

Table

Tables help make complex information easier to scan and compare. Use tables for exact values or information that would be hard to read in body text.

View in FigmaView in StorybookView in Github
import { ... } from '@ag.ds-next/react/table';

Usage

Table components can be imported via the table entrypoint in the @ag.ds-next/react package.

For example:

import { ... } from '@ag.ds-next/react/table';

Props

TableWrapper Props
PropTypeDescription
childrenReactNode
Table Props
PropTypeDescription
aria-describedby?stringThe id of the element that describes the table
aria-labelledby?stringThe id of the element that labels the table
aria-rowcount?numberThe total number of rows in the table
children?ReactNode
id?stringThe id of the table
ref?Ref<HTMLTableElement>
striped?booleanIf true, alternating rows will have a different background colour.
tabIndex?numberSetting this to -1 allows the table to be focusable.
tableLayout?"fixed" | "auto"Default: "auto"The table-layout CSS property sets the algorithm used to lay out cells, rows, and columns.
TableHeader Props
PropTypeDescription
children?ReactNode
display?ResponsiveProp<"none" | "table-cell">Can be used to conditionally hide or show table cells at different breakpoints.
scope?"row" | "rowgroup" | "col" | "colgroup"Defines the cells that the header (defined in the <th>) element relates to.
textAlign?"left" | "right" | "center"Default: "left"Sets the horizontal alignment of the content.
width?ResponsiveProp<string | number>Sets the width of the column.
TableHeaderSortable Props
PropTypeDescription
children?ReactNode
onClick?(() => void)Callback function for when the column header is clicked.
sort?TableSortDirectionThe active direction this column is being sorted by.
textAlign?"left" | "right" | "center"Default: "left"Sets the horizontal alignment of the content.
width?ResponsiveProp<string | number>Sets the width of the column.
TableCaption Props
PropTypeDescription
childrenReactNode
TableHead Props
PropTypeDescription
childrenReactNode
TableBody Props
PropTypeDescription
childrenReactNode
TableRow Props
PropTypeDescription
aria-rowindex?numberThe row index of the table row.
children?ReactNode
selected?booleanIndicates the current selected state of the table row.
TableCell Props
PropTypeDescription
as?"td" | "th"Default: "td"The HTML element to render.
children?ReactNode
display?ResponsiveProp<"none" | "table-cell">Can be used to conditionally hide or show table cells at different breakpoints.
fontWeight?"normal" | "bold"Default: "normal"Sets the font weight of the cell.
scope?"row" | "rowgroup"Essential if you are using TableCell as a row header (as="th"). This defines the cells that the header (defined in the <th>) element relates to.
textAlign?"left" | "right" | "center"Default: "left"Sets the horizontal alignment of the content.
verticalAlign?"bottom" | "top" | "middle"Default: "top"Sets the vertical alignment of the content.
TableBatchActionsBar Props
PropTypeDescription
children?ReactNode
TableBatchActionsTitle Props
PropTypeDescription
children?ReactNode

Source

You can view the full source code for this package on Github.