Row actions
Buttons on a list row, like Open, Copy and Start, that keyboards and agents reach without selecting the row or changing a MasterDetail's detail.
Environments
3 runningA grid, not a listbox
A listbox option can't hold buttons: screen readers flatten it to its text, and its keys belong to the list. So List rowActions turns the list into an APG layout grid. Each row is a primary cell, the row's own link or button that selects or opens it, and one cell per action. The grid is still one tab stop, and a row's actions are a key away instead of a Tab each.
| Key | What it does |
|---|---|
| Up, Down, j, k | The row above or below, in the same column (its last cell when it has fewer). |
| Left, Right | The previous or next cell of the row, following the text direction. |
| Home, End | The row's primary cell or its last action; with Ctrl or ⌘, the grid's first or last cell. |
| Page Up, Page Down | About a screen of rows. |
| Enter, Space | Press the focused cell: the row's link or button, or the action. |
| Tab | Leave the grid; Tab back returns to the cell focused last. |
- Selectable (
value,onValueChange), rows carryaria-selected, and an arrow onto a primary cell or a press on it selects, as in a listbox. Moving through action cells, or pressing one, never does. - In a MasterDetail, the row's primary cell opens it, and
followFocusfollows the primary cells only: an action on another row leaves the detail where it is. - On a mouse or trackpad the actions show while the row is hovered, holds focus or is selected;
rowActionsVisibility="always"keeps them shown. A touch screen always shows them, and each button's hit area reaches 44px. - An action with
disabledstays focusable and says why in its tooltip (a string); an action withhrefis a link, for navigation only.
ListRowAction
| Field | What it does |
|---|---|
id | The same on every row that offers the action; agents run it by its label and the row's id. |
label | Names the button, its tooltip with an icon, and the action for agents. |
icon | A lucide icon: the button shows only the icon. |
onAction(details) | Runs on a press and on an agent's run; details.cancel() refuses it. |
href, newTab | Makes it a link, like opening the row's URL. |
disabled | true, or why it can't run on this row now. |
confirm | The data-agent-confirm sentence: an agent asks a person first. Use it for anything destructive. |
tone | "destructive" colours the button. |
rowActionLabels renames the buttons (button(action, title)) and the actions agents see (group(action)), for instance when two lists on a page share an action.
Agents
Agents see one component per action, named by its label, whose run(id) takes the row's id and lists the rows that offer it, rendered or not. The rows' own buttons stay out of the snapshot, so a long list doesn't fill it. A row that doesn't offer the action, a disabled one, or a run the app cancels fails the step with why, and a confirm action waits for the person through your allow.