Keyboard Navigation for Table Rows
To enable keyboard navigation for table rows, specify
keyboardNavigation="row" in your React Infinite Table component.When row navigation is enabled, clicking a row highlights it and the user can use the arrow keys to navigate the table rows.
- Use
ArrowUpandArrowDownto navigate to the previous and next row. - Use
PageUpandPageDownto navigate the rows vertically by pages (a page is considered equal to the visible row count). - Use
HomeandEndto navigate vertically to the first and last row respectively
Using a default active row#
You can also specify an initial active row, by using
defaultActiveRowIndex=2. This tells the table that there should be a default active row, namely the one at index 2 (so the third row).Listening to active row changes#
You can easily listen to changes in the row navigation by using the
onActiveRowIndexChange callback.When you use controlled
activeRowIndex, make sure to use onActiveRowIndexChange to update the prop value, as otherwise the component will not update on navigationToggling group rows#
When the DataSource is grouped, you can use the keyboard to collapse/expand group rows, by pressing the
Enter key on the active row.Since you're in row navigation mode, you can also use
←to collapse a group row→to expand a group row
#
Press the
Enter key on the active group row to toggle it. ArrowLeft will collapse a group row and ArrowRight will expand a group row.loading demo…
Selecting Rows with the Keyboard#
When
rowSelection is enabled (read more about it in the row selection page), you can use the spacebar key to select a group row (or shift + spacebar to do multiple selection).By default
keyboardSelection is enabled, so you can use the spacebar key to select multiple rows, when selectionMode="multi-row". Using the spacebar key is equivalent to doing a mouse click, so expect the combination of spacebar + cmd/ctrl/shift modifier keys to behave just like clicking + the same modifier keys.#
Multi row selection with keyboard support
Use spacebar + optional
cmd/ctrl/shift modifier keys just like you would do clicking + the same modifier keys.loading demo…
For selection all the rows in the table, you can use
cmd/ctrl + A keyboard shortcut.Keyboard selection is also possible when there's a column configured with checkbox selection - make sure you read more about it.
Theming#
By default, the style of the element that highlights the active row is the same style as that of the element that highlights the active cell.
The easiest is to override the style is via those three CSS variables:
--infinite-active-cell-border-color--r- theredcomponent of the border color--infinite-active-cell-border-color--g- thegreencomponent of the border color--infinite-active-cell-border-color--b- thebluecomponent of the border color
The initial values for those are
77, 149 and215 respectively, so the border color is rgb(77, 149, 215).In addition, the background color of the element that highlights the active row is set to the same color as the border color (computed based on the above
r, g and b variables), but with an opacity of 0.25, configured via the --infinite-active-row-background-alpha CSS variable.When the table is not focused, the opacity for the background color is set to
0.1, which is the default value of the --infinite-active-row-background-alpha--table-unfocused CSS variable.To summarize, use
--infinite-active-cell-border-color--r--infinite-active-cell-border-color--g--infinite-active-cell-border-color--b
to control border and background color of the active row highlight element.
No, it's not a mistake that the element that highlights the active row is configured via the same CSS variables as the element that highlights the active cell. This is deliberate - so override CSS variables for cell, and those are propagated to the row highlight element.
There are other CSS variables as well, that give you fined-tuned control over both the border and background color for the active row, if you don't want to use the above three variables to propagate the same color across both border and background.
--infinite-active-cell-background- the background color. If you use this, you need to set opacity yourself. Applied for both cell and row.--infinite-active-row-background- the background color. If you use this, you need to set opacity yourself. If this is specified, it takes precendence over--infinite-active-cell-background--infinite-active-cell-background- the background color. If you use this, you need to set opacity yourself. Applied for both cell and row.--infinite-active-row-background- the background color. If this is specified, it takes precedence over--infinite-active-cell-background--infinite-active-row-border- border configuration (eg:2px solid magenta). If you use this, it will not be propagated to the background color.
For more details on the CSS variables, see the CSS Variables documentation.
#
Theming active row highlight
Use the color picker to configured the desired color for the active row highlight
loading demo…