# Cell Select

A compact select for inline use in a Data Table cell.

- Category: Forms
- Page: https://wunderui.com/components/cell-select
- Tier: Free

## Install

```bash
npx wunderui-cli add cell-select
```

## Import

```tsx
import { CellSelect } from "@/components/wunderui/table-cells"
```

## Minimal usage

Then use it inside a table cell:

```tsx
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.

## Usage

```tsx
import { useState } from "react"
import { CellSelect } from "@/components/ui/cell-select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const ROLES = ["Admin", "Editor", "Viewer"]

const MEMBERS = [
  { name: "Nora Lindgren", role: "Admin" },
  { name: "Daniel Okafor", role: "Editor" },
  { name: "Priya Raman", role: "Viewer" },
]

export function Example() {
  const [members, setMembers] = useState(MEMBERS)
  const setRole = (name: string, role: string) =>
    setMembers((rows) => rows.map((row) => (row.name === name ? { ...row, role } : row)))
  
  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Team members">
        <TableHeader>
          <TableRow>
            <TableHead>Member</TableHead>
            <TableHead className="w-40">Role</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {members.map((member) => (
            <TableRow key={member.name}>
              <TableCell role="rowheader" className="font-medium">{member.name}</TableCell>
              <TableCell>
                <CellSelect
                  aria-label={`Role of ${member.name}`}
                  value={member.role}
                  onValueChange={(role) => setRole(member.name, role)}
                  options={ROLES}
                />
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## 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

- [Select](https://wunderui.com/components/select) for a select in a form, with a visible label and helper text
- [Combobox](https://wunderui.com/components/combobox) for a long list or options that people need to search
- [Radio Group](https://wunderui.com/components/radio-group) for two or three options that should all stay visible

## Keyboard

The trigger is a button with the combobox role. The list is the Base UI select popup, so it traps focus while open.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the next or previous control in the table, row by row. Each trigger is one Tab stop. |
| `Enter` or `Space` | On the closed trigger: opens the list with the current value highlighted. |
| `ArrowDown` or `ArrowUp` | In the open list: moves the highlight to the next or previous option. |
| `Enter` | In the open list: chooses the highlighted option, calls `onValueChange` 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

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

- `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.
- `Row header`: 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.
- `CellSelect`: 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.
- `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).
- `Value`: The current value on one line in 12 px text. A value longer than the trigger is cut with an ellipsis.
- `Chevron`: The down chevron at the right edge of the trigger. It stays inside the border at every value length.
- `Options list`: 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.
- `Option`: 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.
- Pass options as the exact strings you store, and keep the value one of them. The value is the text, with no separate label.
- Keep options short, up to about 14 characters. The trigger shows one line in 128 px and cuts the rest with an ellipsis.
- 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 use it in a form with a label. There NativeSelect with its Label and helper text is the right control.
- Don't pass a value that is not in the options. No option is checked and the list has no starting point.
- Don't expect a saving, error or disabled look. CellSelect has no such props, unlike the Editable Cell states in Figma.

## API reference

### CellSelect

| Prop | Type | Default | Description |
|---|---|---|---|
| onValueChange* | (value: string) => void |  | Called with the option string the person chose. It is not called for an empty value. |
| options* | string[] |  | The options as plain strings. Each string is shown in the list and is also the value that is stored. |
| value* | string |  | The current option. It is a controlled value and must be one of `options`; write the new one back in `onValueChange`. |
| aria-label | string |  | The name for screen readers. A cell has no visible label, so give each select its row and column, such as `Role of Nora Lindgren`. The default is `Choose a value`. |

## Examples

### Options: a short list, long labels and many options

```tsx
import { useState } from "react"
import { CellSelect } from "@/components/ui/cell-select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const STATUSES = ["Active", "Paused", "Archived"]

const MEMBERS = [
  { name: "Nora Lindgren", status: "Active" },
  { name: "Daniel Okafor", status: "Paused" },
  { name: "Priya Raman", status: "Archived" },
]

export function Example() {
  const [members, setMembers] = useState(MEMBERS)
  const setStatus = (name: string, status: string) =>
    setMembers((rows) => rows.map((row) => (row.name === name ? { ...row, status } : row)))
  
  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Team members">
        <TableHeader>
          <TableRow>
            <TableHead>Member</TableHead>
            <TableHead className="w-40">Status</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {members.map((member) => (
            <TableRow key={member.name}>
              <TableCell role="rowheader" className="font-medium">{member.name}</TableCell>
              <TableCell>
                <CellSelect
                  aria-label={`Status of ${member.name}`}
                  value={member.status}
                  onValueChange={(status) => setStatus(member.name, status)}
                  options={STATUSES}
                />
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## In context

### Sprint tasks: change the status in the row

The Status column edits each task in place and the count above follows. Every select is named after its task, such as Status of Fix coupon rounding.

```tsx
import { useState } from "react"
import { Badge } from "@/components/ui/badge"
import { CellSelect } from "@/components/ui/cell-select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const STATUSES = ["To do", "In progress", "Done"]

const TASKS = [
  { name: "Write release notes", owner: "Nora Lindgren", status: "In progress" },
  { name: "Fix coupon rounding", owner: "Daniel Okafor", status: "Done" },
  { name: "Update pricing page", owner: "Priya Raman", status: "To do" },
  { name: "Review checkout copy", owner: "Tomás Ferreira", status: "In progress" },
]

export function Example() {
  const [tasks, setTasks] = useState(TASKS)
  const setStatus = (name: string, status: string) =>
    setTasks((rows) => rows.map((row) => (row.name === name ? { ...row, status } : row)))
  const done = tasks.filter((task) => task.status === "Done").length

  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <div className="flex items-center justify-between gap-4 border-b border-border px-4 py-3">
        <p className="text-sm font-semibold text-foreground">Sprint 14</p>
        <Badge color={done === tasks.length ? "green" : "indigo"} badgeStyle="light" shape="pill">
          {done} of {tasks.length} done
        </Badge>
      </div>
      <Table aria-label="Sprint 14 tasks">
        <TableHeader>
          <TableRow>
            <TableHead>Task</TableHead>
            <TableHead>Owner</TableHead>
            <TableHead className="w-40">Status</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {tasks.map((task) => (
            <TableRow key={task.name}>
              <TableCell role="rowheader" className="font-medium">{task.name}</TableCell>
              <TableCell>{task.owner}</TableCell>
              <TableCell>
                <CellSelect
                  aria-label={`Status of ${task.name}`}
                  value={task.status}
                  onValueChange={(status) => setStatus(task.name, status)}
                  options={STATUSES}
                />
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

### Support queue: two select columns

Priority and Assignee are separate columns. The ticket is the row header, so a screen reader hears the ticket, the column and the value.

```tsx
import { useState } from "react"
import { CellSelect } from "@/components/ui/cell-select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const PRIORITIES = ["Low", "Medium", "High", "Urgent"]
const ASSIGNEES = ["Nora Lindgren", "Daniel Okafor", "Priya Raman", "Maya Kessler"]

const TICKETS = [
  { name: "Refund not received", customer: "Tomás Ferreira", priority: "High", assignee: "Priya Raman" },
  { name: "Cannot reset password", customer: "Maya Kessler", priority: "Urgent", assignee: "Nora Lindgren" },
  { name: "Invoice shows wrong VAT", customer: "Daniel Okafor", priority: "Medium", assignee: "Maya Kessler" },
]

export function Example() {
  const [tickets, setTickets] = useState(TICKETS)
  const update = (name: string, patch: { priority?: string; assignee?: string }) =>
    setTickets((rows) => rows.map((row) => (row.name === name ? { ...row, ...patch } : row)))

  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Support queue">
        <TableHeader>
          <TableRow>
            <TableHead>Ticket</TableHead>
            <TableHead className="w-40">Priority</TableHead>
            <TableHead className="w-40">Assignee</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {tickets.map((ticket) => (
            <TableRow key={ticket.name}>
              <TableCell role="rowheader" className="font-medium">
                {ticket.name}
                <span className="block text-xs font-normal text-text-tertiary">{ticket.customer}</span>
              </TableCell>
              <TableCell>
                <CellSelect
                  aria-label={`Priority of ${ticket.name}`}
                  value={ticket.priority}
                  onValueChange={(priority) => update(ticket.name, { priority })}
                  options={PRIORITIES}
                />
              </TableCell>
              <TableCell>
                <CellSelect
                  aria-label={`Assignee of ${ticket.name}`}
                  value={ticket.assignee}
                  onValueChange={(assignee) => update(ticket.name, { assignee })}
                  options={ASSIGNEES}
                />
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## For AI agents

`get_component("cell-select")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
