IconLogoMark
IconUiExpandCollapseDown

Release NotesIconUiExpandCollapseDown

ComponentsIconUiExpandCollapseDown

AvatarsIconUiExpandCollapseDown
ButtonsIconUiExpandCollapseDown
Data VisualizationIconUiExpandCollapseDown
DialogsIconUiExpandCollapseDown
FormsIconUiExpandCollapseDown
IconsIconUiExpandCollapseDown
ModulesIconUiExpandCollapseDown
NotificationsIconUiExpandCollapseDown
ThemesIconUiExpandCollapseDown
TypeIconUiExpandCollapseDown

GuidelinesIconUiExpandCollapseDown

PatternsIconUiExpandCollapseDown

WordsIconUiExpandCollapseDown

ResourcesIconUiExpandCollapseDown

Data Table

/

Code

Organize static data for easy consumption and understanding.

The data table allows both Hudl and the user to clearly display large sets of information for the sake of visualizing data.

Web
React Native
Android
Apple
IconWarning
Version 5+
If using Uniform Version 5 or later, please refer to our Storybook docs for the Data Table API and examples.
Name
Jersey
Position
HeightWeight
Rawle Alkins20SG6'5"225 lbs
Chandler Hutchinson15SF6'7"197 lbs
Zach LaVine8PG6'7"200 lbs
<DataTable
  style="freeform"
  size="medium"
  columnContentTypes={["text", "text", "text", "text", "text"]}
  columnShowSortArrows={[true, true, true, false, false]}
  columnHeaders={["Name", "Jersey", "Position", "Height", "Weight"]}
  rows={[
    {id: '1', data: ['Rawle Alkins', '20', 'SG', '6\'5"', '225 lbs']},
    {id: '2', data: ['Chandler Hutchinson', '15', 'SF', '6\'7"', '197 lbs']},
    {id: '3', data: ['Zach LaVine', '8', 'PG', '6\'7"', '200 lbs']}
  ]}
/>

Props

Visual


className

string

A class to apply to the main data table element.

columnContentTypes

   REQUIRED

('text' | 'numeric' | 'selectmark' | 'element')[]

The content types of each column in your data table. Acceptable values are:

  • text
  • numeric
  • selectmark

columnHeaders

   REQUIRED

string[]

The text to display in the column headers.

columnShowSortArrows

boolean[]

Whether or not each column in your data table should show sort arrows. This also switches on the sort functionality for a column when true.

environment

string

Determines the environment applied.

  • light (default)
  • dark

rows

   REQUIRED

Rows[]

The data to show. Each row must include an id and data like so:

{id: '1', data: ['Rawle Alkins', '20', 'SG', '6\'5"', '225 lbs']},
{id: '2', data: ['Chandler Hutchinson', '15', 'SF', '6\'7"', '197 lbs']},
{id: '3', data: ['Zach LaVine', '8', 'PG', '6\'7"', '200 lbs']}

To include arbitrary React elements within the table cells, pass an object with value and element props like so:

{
  id: '1',
  data: [
    {
      value: 'bask-foot',
      element: (
        <>
          <IconBasketball />
          <IconFootball />
        </>
      ),
    },
    'Rawle Alkins',
    '20',
    'SG',
    '6\'5"',
    '225 lbs',
  ],
}

rowsChecked

string[]

Determines which rows have their Select Marks checked.

rowsSelected

string[]

Determines which rows are selected.

showTableBorder

boolean

Determines whether a border surrounds the entire data table.

size

string

Determines the size of the data table. Acceptable values are:

  • xsmall
  • small
  • medium - (default)
  • large

style

string

Determines the style of the data table. Acceptable values are:

  • default - (default)
  • freeform
  • striped

title

string

Determines the title of the data table. Will be rendered as a <caption> element. If no title is provided, please use aria-describedby instead.

Functional


columnDefaultSortIndex

number

Pass in the index of the column you want a default sort applied to. Starts at 0.

columnDefaultSortDirection

string

Determines how you want your default sort applied. Acceptable values are:

  • ascending - default
  • descending

freezeFirst

string

Determines whether to freeze the first row or column when scrolling. Acceptable values are:

  • row - default
  • column

Events


onRowClick

(rowId: string) => void

Responds to a row being clicked. Passes back the id of the row.

onSelectMarkClick

(rowId: string) => void

Responds to a row's Select Mark being clicked. Passes back the id of the row. If the Select Mark in the header is clicked, 'all-rows-checked' is passed back.

Accessibility


aria-describedby

string

If you choose not to use the title property, use the aria-describedby property to associate the table with an alternate header element for accesssibility purposes. See the MDN documentation to learn more.

Notes

  • Including selectmark as a column content type will automatically put a select mark in that row, but your data must account for that (you can put an empty string in for that particular column).

Accessibility

Audit Results

See our full accessibility audit for more information about these results.

VisualInteractiveAutomatedDetails
IconConfirmation PassIconCritical ViolationIconConfirmation Pass
  • IconCriticalRows cannot be selected using the keyboard.