# Product Inventory block

> Inline-editable product inventory data grid with per-cell validation and a dirty-state save bar

Edit inventory rows in place with text, number, and select cell editors, live validation, and a dirty-tracking Save / Discard bar. Search, status filter, add, duplicate, delete. ReUI DataGrid, Frame, Badge with shadcn Input, Select, Switch.

- Type: Pro block
- Category: [Editing](https://web.dev.reui.io/blocks/data-grid/editing.md)
- Page: https://web.dev.reui.io/blocks/data-grid/editing/data-grid-editing-2
- Docs (Base UI): https://web.dev.reui.io/docs/components/base/data-grid.md
- Docs (Radix UI): https://web.dev.reui.io/docs/components/radix/data-grid.md
- MCP: `get_block("data-grid-editing-2")`
- Built with: Alert Dialog, Badge, Button, Data Grid, Dropdown Menu, Frame, Input, Input Group, Select, Switch, Tooltip
- Installs with a ReUI Pro or Ultimate license; setup: https://web.dev.reui.io/docs/license-setup

## Best for

Product rows edited one cell at a time and saved in one batch, with a low stock flag at 10 units or fewer and a storefront switch

## Agent notes

- `PRODUCTS` seeds both `savedRows` and `rows` in `InventoryEditingDataGridView`; load your own products there
- `handleSave` copies `rows` into `savedRows` and shows a toast saying to connect your product API; send the changes there
- `validatePrice` caps price at 100000 and `validateStock` needs a whole number; change them to your catalog rules

## When not to use

- Range selection, paste and drag to fill across many cells at once: use [Task Spreadsheet](https://web.dev.reui.io/blocks/data-grid/editing/data-grid-editing-5.md) (`get_block("data-grid-editing-5")`)
- One record edited and saved on its own, with no batch save bar: use [Pricing Plan Editor](https://web.dev.reui.io/blocks/data-grid/editing/data-grid-editing-4.md) (`get_block("data-grid-editing-4")`)

## Third-party libraries

- TanStack Table v9: [API reference](https://tanstack.com/table/v9/docs/framework/react/reference/index), [docs](https://tanstack.com/table/v9/docs/framework/react/quick-start)
- Sonner v2: [API reference](https://sonner.emilkowal.ski/toast), [docs](https://sonner.emilkowal.ski/getting-started)

## Install

```bash
npx shadcn@latest add @reui/data-grid-editing-2
```

## About Editing blocks

### When to use

- Admin tables whose values are typed into cells or rows, validated, then saved or discarded
- Spreadsheet work over long lists: cell ranges, paste, drag to fill and undo
- Small catalogs such as labels or pricing plans, where one record is edited and saved at a time

### When not to use

- Cell editing added to a table you already build from parts in your own layout: use [Data Grid](https://web.dev.reui.io/components/data-grid.md) (`get_component("data-grid")`)
- Rows that are only browsed, filtered and paged, with no values changed in the cells: use the [Base blocks](https://web.dev.reui.io/blocks/data-grid/base.md)
- A plain list reordered by drag, with no form to add or rename its items: use [Sortable](https://web.dev.reui.io/components/sortable.md) (`get_component("sortable")`)

### Agent notes

- Every page.tsx renders an sr-only `h1` inside a centered `min-h-svh` main; remove that wrapper when the view sits in your own page
- Rows start from a data file constant held in `useState` or `useReducer`, and nothing reaches a server; call your API where each edit or save commits

Every ReUI item has a twin like this one; the index is https://web.dev.reui.io/llms.txt. Agents with the ReUI MCP (https://web.dev.reui.io/docs/mcp) get the same guidance from the getters named above.
