Make a matrix an interactive ARIA grid: screen readers announce its rows and cells, and it is keyboard navigable.
Roles: a single layer matrix becomes the grid (role grid with aria-rowcount / aria-colcount, its layer a
rowgroup), a matrix of several layers a group of grids, one per layer, labelled "Layer 1", "Layer 2", ... Each row
is a row and each column a gridcell. Attributes already set (from the matrix props) are kept, so give the grid
its name there, e.g. square({ matrix: { attributes: { 'aria-label': 'Your board' } } }, 10).
Keyboard, following the ARIA grid pattern: the matrix is a single Tab stop (the start
cell, then whichever cell was used last), the arrow keys move between cells, Home / End go to the start / end
of the row, Ctrl+Home / Ctrl+End to the first / last cell, Page Up / Page Down change layer, and Enter or Space
clicks the focused cell.
Only for a grid people interact with cell by cell (a game board, a seat map): a layout of cards is not a grid.
Call it before rendering the matrix. The cells themselves take focus, so put the click listener on the matrix
(or the cells) rather than on buttons inside the cells.
Make a matrix an interactive ARIA grid: screen readers announce its rows and cells, and it is keyboard navigable.
Roles: a single layer matrix becomes the grid (role grid with aria-rowcount / aria-colcount, its layer a rowgroup), a matrix of several layers a group of grids, one per layer, labelled "Layer 1", "Layer 2", ... Each row is a row and each column a gridcell. Attributes already set (from the matrix props) are kept, so give the grid its name there, e.g.
square({ matrix: { attributes: { 'aria-label': 'Your board' } } }, 10).Keyboard, following the ARIA grid pattern: the matrix is a single Tab stop (the start cell, then whichever cell was used last), the arrow keys move between cells, Home / End go to the start / end of the row, Ctrl+Home / Ctrl+End to the first / last cell, Page Up / Page Down change layer, and Enter or Space clicks the focused cell.
Only for a grid people interact with cell by cell (a game board, a seat map): a layout of cards is not a grid. Call it before rendering the matrix. The cells themselves take focus, so put the click listener on the matrix (or the cells) rather than on buttons inside the cells.