Cell Select
FreeA compact select for a table cell. It edits one value of a row in place, such as a role, a status or a team.
npx wunderui-cli add cell-selectPlayground
| Member | Role |
|---|---|
| Nora Lindgren | |
| Daniel Okafor | |
| Priya Raman |
| Member | Status |
|---|---|
| Nora Lindgren | |
| Daniel Okafor | |
| Priya Raman |
| Member | Team |
|---|---|
| Nora Lindgren | |
| Daniel Okafor | |
| Priya Raman |
Installation
npx wunderui-cli add cell-selectWrites the source into your project with its dependencies and, on first use, the styles - see Installation.
Then import what you need:
import { CellSelect } from "@/components/wunderui/table-cells"Then use it inside a table cell:
import { useState } from "react"
import { CellSelect } from "@/components/ui/cell-select"
import { TableCell } from "@/components/ui/table"
export function RoleCell({ member }: { member: string }) {
const [role, setRole] = useState("Editor")
return (
<TableCell>
<CellSelect
aria-label={`Role of ${member}`}
value={role}
onValueChange={setRole}
options={["Admin", "Editor", "Viewer"]}
/>
</TableCell>
)
}Expected result: You see a small select showing Editor. Click it or press Enter to open a list of Admin, Editor and Viewer with a check on Editor, and choose one to change the value.
When to use
Use Cell Select for
- Editing one value of a row in place, such as a role, a status, a priority or a team
- Short lists of three to eight options that people know
- A column where every row picks from the same options
Use something else for
- Select for a select in a form, with a visible label and helper text
- Combobox for a long list or options that people need to search
- Radio Group for two or three options that should all stay visible
Options
Options are a plain list of strings. The trigger is 128 px wide and shows one line, so keep labels short.
| Member | Status |
|---|---|
| Nora Lindgren | |
| Daniel Okafor | |
| Priya Raman |
| Member | Status |
|---|---|
| Nora Lindgren | |
| Daniel Okafor | |
| Priya Raman |
| Member | Team |
|---|---|
| Nora Lindgren | |
| Daniel Okafor | |
| Priya Raman |
Keyboard interactions
The trigger is a button with the combobox role. The list is the Base UI select popup, so it traps focus while open.
- TaborShift+Tab
- Moves focus to the next or previous control in the table, row by row. Each trigger is one Tab stop.
- EnterorSpace
- On the closed trigger: opens the list with the current value highlighted.
- ArrowDownorArrowUp
- In the open list: moves the highlight to the next or previous option.
- Enter
- In the open list: chooses the highlighted option, calls and returns focus to the trigger.
- Escape
- Closes the list without a change and returns focus to the trigger.
In this version, typing a letter does not jump to the option that starts with it.
Behavior and motion
What the cell select does itself, and what it leaves to the table around it.
- Controlled
- CellSelect keeps no state. You supply the value, a choice calls the change handler with the option string, and nothing changes until you set the value.
- Options are strings
- Options are a list of strings, and the value is one of them. For a label that differs from the stored value, use NativeSelect with its own items.
- Accessible name
- A combobox is not named by its current value, and a cell has no visible label. Set an aria-label per row and column, such as Role of Nora Lindgren, since the default is the same in every row.
- Table context
- With the first cell marked as a row header, a screen reader in table mode reads row, column and value together. In forms mode only the trigger is read, so its label must carry row and column.
- Width and long values
- The trigger is 32 px high and 128 px wide, in 12 px text, and a value that does not fit is cut with an ellipsis. The list is as wide as the trigger, so a long option wraps and stays readable.
- The list
- The list opens below the trigger, never over it, and is not clipped by the table card. The chosen option shows a check, and the highlighted one takes the page background.
- Focus
- The trigger shows the focus ring (an indigo border and a 2 px ring) and a primary border while the list is open.
- Figma states
- The Figma Editable Cell set has View, Edit, Changed, Saving, Error and Disabled, but CellSelect has no props for them. For a disabled or invalid select, use NativeSelect in the cell.
- Motion
- The list fades and scales out of its anchor and leaves faster. The trigger border changes quickly.
- Reduced motion
- With reduced motion the list opens and closes without a transition.
Anatomy
The figure marks one select in its row: the row header, the trigger, the value and the chevron. The options list opens on demand, so it is described below the figure.
| Member | Role |
|---|---|
| Nora |
- data-slot="table"
The table the cell sits in. The first column holds the row names, the header row names the columns, and the select lives in a table cell.
- 1
The first cell of the row, marked as the row header. It says which row the select belongs to, so a screen reader reads it with the select.
A compact select for a table cell: a 32 px trigger, 128 px wide, with a plain list of strings as options. You hold the value and write it back on change.
- 2data-slot="native-select-trigger"
The button that shows the current value and opens the list. It has no visible label, so give it an aria-label (default Choose a value).
- 3data-slot="native-select-value"
The current value on one line in 12 px text. A value longer than the trigger is cut with an ellipsis.
- 4
The down chevron at the right edge of the trigger. It stays inside the border at every value length.
- data-slot="native-select-content"
The popup under the trigger, as wide as the trigger. A long option wraps onto more lines here, so the full text is always readable.
- data-slot="native-select-item"
One row of the list for each option string. The highlighted option takes the page background and the chosen one shows a check.
Best practices
- Do
Set an aria-label per row and column, such as Role of Nora Lindgren. A trigger that shows only its value does not name itself to a screen reader.
- Do
Pass options as the exact strings you store, and keep the value one of them. The value is the text, with no separate label.
- Do
Keep options short, up to about 14 characters. The trigger shows one line in 128 px and cuts the rest with an ellipsis.
- Do
Mark the first cell of each row as a row header, so a screen reader reads the row, the column and the value together.
- Don’t
Don't use it for long lists or options that need a description. It has no search or groups, so use a Combobox.
- Don’t
Don't use it in a form with a label. There NativeSelect with its Label and helper text is the right control.
- Don’t
Don't pass a value that is not in the options. No option is checked and the list has no starting point.
- Don’t
Don't expect a saving, error or disabled look. CellSelect has no such props, unlike the Editable Cell states in Figma.
API reference
CellSelect is a plain function component with four props. It renders a NativeSelect and sets the trigger size and the list itself, passing no other props through.
A compact select for a table cell: a 32 px trigger, 128 px wide, with a plain list of strings as options. You hold the value and write it back on change.
| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | — | The current option. It is a controlled value and must be one of ; write the new one back in . |
| onValueChange required | (value) => void | — | Called with the option string the person chose. It is not called for an empty value. |
| options required | string[] | — | The options as plain strings. Each string is shown in the list and is also the value that is stored. |
| aria-label | string | — | The name for screen readers. A cell has no visible label, so give each select its row and column, such as . The default is . |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("cell-select")npx wunderui-cli add cell-selectThe full library index for assistants is at /llms.txt.
Related components
Recent invoicesInvoices issued in the last 30 days Invoice Status Customer Amount INV-2041 Paid WunderUI $24,800.00 INV-2040 Open Halcyon Labs $3,200.00 INV-2039 Overdue Pergola Foods $980.00 INV-2038 Paid Marlow & Finch $12,400.00 Total Sum$41,380.00 Core Elements5 stylesTableRows and columns with 23 ready-made cell types; for sorting and search use Data Table.