# Cell Slider

A compact progress/value slider for inline use in a Data Table cell.

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

## Install

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

## Import

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

## Minimal usage

Then use it inside a table cell:

```tsx
import { CellSlider } from "@/components/ui/cell-slider"
import { TableCell } from "@/components/ui/table"

export function QuotaCell({ used }: { used: number }) {
  return (
    <TableCell>
      <CellSlider value={used} max={100} />
    </TableCell>
  )
}
```

Expected result: You see a thin grey bar with a primary-coloured fill and the number to its right. At a value of 68 the fill covers 68 % of the bar.

## Usage

```tsx
import { CellSlider } from "@/components/ui/cell-slider"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const MEMBERS = [
  { name: "Nora Lindgren", value: 68 },
  { name: "Daniel Okafor", value: 42 },
  { name: "Priya Raman", value: 91 },
]

export function Example() {
  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">Quota used</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {MEMBERS.map((member) => (
            <TableRow key={member.name}>
              <TableCell role="rowheader" className="font-medium">{member.name}</TableCell>
              <TableCell><CellSlider value={member.value} /></TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## When to use

### Use Cell Slider for

- Showing a level inside a table row, such as a quota used, a score or a share
- A column of bars that people compare at a glance
- Values that are set somewhere else and only read here

### Use something else

- [Slider](https://wunderui.com/components/slider) for a value the person changes by dragging or with the arrow keys
- [Progress](https://wunderui.com/components/progress) for the completion of one task or upload, with a label and a role
- [Meter](https://wunderui.com/components/meter) for a value in a known range with thresholds, such as disk usage

## Behavior

What the cell slider shows and what it leaves out.

- **Read-only:** CellSlider takes only a value and a maximum. It has no handler, cannot be focused or dragged and takes no key, so change the bar by changing the value.
- **Fill:** The fill is clamped between 0 and 100 %: empty at 0 or below, full at the maximum or above. The number always shows what you passed, so 130 of 100 fills the bar and still reads 130.
- **No role, no name:** The bar has no ARIA role or label, so a screen reader reads only the number. Name the measure in the column header and the row in a row header, and put the unit in the header.
- **Number:** The number is the raw value in a 28 px box, right-aligned. Up to three digits line up in a column, and longer ones widen the box and shorten the bar.
- **Width:** The cell is 112 px wide. Give its column about 160 px so the header and the bar line up.
- **Figma states:** The Figma Editable Cell set shows a draggable Slider in six states, but in React CellSlider only displays a level. For a value people change, use Slider in the cell.
- **Motion:** Nothing moves. The fill changes width in one step when the value changes.
- **Reduced motion:** There is no movement to remove, so reduced motion changes nothing.

## Anatomy

- `Table`: The table the cell sits in. The first column holds the row names, the header row names the columns, and the bar lives in a table cell.
- `Column header`: The header of the bar column. It names the measure and the unit, such as Quota used, because the bar itself has no label.
- `Row header`: The first cell of the row, marked as the row header. It says whose level the bar shows.
- `CellSlider`: A small bar, 112 px wide, with a number beside it. It shows a value out of a maximum (default 100) and cannot be dragged, since it is a display, not a control.
- `Track`: The 4 px grey bar with fully rounded ends. It always spans the width left of the number.
- `Fill`: The primary-coloured part of the track. Its width is the value divided by the maximum, capped at 100 %.
- `Number`: The raw value to the right of the bar, 12 px and right-aligned in 28 px, so the bar never has to be read on its own.

## Best practices

### Do

- Set the maximum to the real ceiling, such as 5 for a 5-point score or the seat limit of the row. The fill is clamped to the track, but the number still shows the raw value.
- Put it in a column whose header names the measure and the unit, such as Quota used. The bar and number have no label or role of their own.
- Mark the first cell of each row as a row header, so the number is read with its row.
- Pair it with a control when the level can change, such as a button that completes a task. The slider then follows the value.

### Don't

- Don't build an editable cell around it. It has no handler, keyboard support or ARIA role, so use a Slider with an aria-label in the cell instead.
- Don't use it for one task or upload with a label and a status. Progress has the role and the text for that.
- Don't rely on the bar for values outside 0 to the maximum. It draws an empty or full bar there, and only the number shows the real figure.
- Don't count on the Figma Editable Cell Slider states (View, Edit, Changed, Saving, Error, Disabled). The React cell shows a level only.

## API reference

### CellSlider

| Prop | Type | Default | Description |
|---|---|---|---|
| value* | number |  | The level to show. The bar is clamped to 0 to `max`: a negative value draws an empty bar and a value above `max` a full one. The number beside the bar always shows the value as given. |
| max | number | 100 | The value that fills the whole bar. The default is 100. Set it to the real ceiling, such as 5 for a 5-point score. A `max` of 0 or less draws an empty bar. |

## Examples

### Value: empty, half, full, over the max, below zero and a max of 0

```tsx
import { CellSlider } from "@/components/ui/cell-slider"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

export function Example() {
  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Quota">
        <TableHeader>
          <TableRow>
            <TableHead>Member</TableHead>
            <TableHead className="w-40">Quota used</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          <TableRow>
            <TableCell role="rowheader" className="font-medium">Nora Lindgren</TableCell>
            <TableCell>
              <CellSlider value={0} max={100} />
            </TableCell>
          </TableRow>
        </TableBody>
      </Table>
    </div>
  )
}
```

## In context

### Epics: complete a task and watch the bar

The bar shows tasks done out of each epic's tasks. The button beside it completes one task, and the bar and number follow, because the slider only displays the level.

```tsx
import { useState } from "react"
import { Check } from "lucide-react"
import { CellSlider } from "@/components/ui/cell-slider"
import { IconButton } from "@/components/ui/icon-button"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const EPICS = [
  { name: "Checkout redesign", owner: "Nora Lindgren", done: 6, total: 10 },
  { name: "Billing migration", owner: "Daniel Okafor", done: 3, total: 12 },
  { name: "Onboarding emails", owner: "Priya Raman", done: 8, total: 8 },
  { name: "Mobile navigation", owner: "Tomás Ferreira", done: 2, total: 9 },
]

export function Example() {
  const [epics, setEpics] = useState(EPICS)
  const complete = (name: string) =>
    setEpics((rows) => rows.map((row) => (row.name === name && row.done < row.total ? { ...row, done: row.done + 1 } : row)))

  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Epics">
        <TableHeader>
          <TableRow>
            <TableHead>Epic</TableHead>
            <TableHead>Owner</TableHead>
            <TableHead className="w-40">Tasks done</TableHead>
            <TableHead className="w-12"><span className="sr-only">Actions</span></TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {epics.map((epic) => (
            <TableRow key={epic.name}>
              <TableCell role="rowheader" className="font-medium">{epic.name}</TableCell>
              <TableCell>{epic.owner}</TableCell>
              <TableCell>
                <CellSlider value={epic.done} max={epic.total} />
              </TableCell>
              <TableCell>
                <IconButton
                  variant="plain"
                  size="sm"
                  aria-label={`Complete a task in ${epic.name}`}
                  disabled={epic.done >= epic.total}
                  onClick={() => complete(epic.name)}
                >
                  <Check />
                </IconButton>
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

### Seats by workspace: each bar against its own limit

Each workspace has its own seat limit, which sets its row's maximum. Support has used all 10 seats and shows a full bar, and the limit has its own column.

```tsx
import { CellSlider } from "@/components/ui/cell-slider"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const WORKSPACES = [
  { name: "Design team", plan: "Team", seats: 6, limit: 10 },
  { name: "Engineering", plan: "Business", seats: 18, limit: 25 },
  { name: "Support", plan: "Team", seats: 10, limit: 10 },
]

export function Example() {
  return (
    <div className="w-full overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Seats by workspace">
        <TableHeader>
          <TableRow>
            <TableHead>Workspace</TableHead>
            <TableHead>Plan</TableHead>
            <TableHead className="w-40">Seats in use</TableHead>
            <TableHead className="w-20 text-right">Limit</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {WORKSPACES.map((workspace) => (
            <TableRow key={workspace.name}>
              <TableCell role="rowheader" className="font-medium">{workspace.name}</TableCell>
              <TableCell>{workspace.plan}</TableCell>
              <TableCell>
                <CellSlider value={workspace.seats} max={workspace.limit} />
              </TableCell>
              <TableCell className="text-right tabular-nums">{workspace.limit}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## For AI agents

`get_component("cell-slider")`

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