shadcn.io is not affiliated with official shadcn/ui
Edit Record Dialog Block for React
An inventory table with a side sheet that edits one item and steps through the rest: name, SKU, quantity, bin, reorder level and notes, an error summary with links, a change line with Reset, and Save and next.
Installation
Overview
Let people work down a list without leaving it, with this edit sheet for React with Base UI. It opens from the Stock page of Binkeeper, an inventory app: the page is a drawn table of eight items, with the one being edited shaded, under a soft scrim inside a hairline frame with a plus mark on each corner, and its header holds an outline Edit items Button. The panel is a Sheet from the end edge, whichever way the page reads. It holds a name Input, the SKU read-only, a quantity and a reorder level in Number Inputs, a bin Select and notes in a Textarea. A line under the fields counts what changed and offers Reset. The previous and next buttons, with "3 of 8" between them, wait until the form is saved or reset. Saving with a problem puts a summary at the top whose links jump to each field. Save and next, the only Shine Button, writes the item to the table behind the sheet, moves on and puts focus in the first field; Save stays on the item, and Ctrl or Command with Enter saves too. For preview the sheet is drawn open in place when the page loads; the header button opens the real Sheet, with the same fields and the same state. For inventories, catalogues, admin tables and any list where people edit many rows in a row.
FAQ
Why is the sheet already open, and what do I keep?
So you can see it without a click. On load the sheet is a copy drawn in place over the page: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Edit items button opens the real Sheet, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same RecordFields component and share the block's state, so a name typed in the copy is there in the real one. In your app keep the Sheet and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.
Why does the sheet come from the end edge?
The catalog's sheet sides are physical, a left and a right, so in a right-to-left page a "right" sheet would open at the wrong edge. The block reads the page's direction when the sheet opens and picks the side that is the end of the line: the right in English, the left in Arabic or Hebrew. On a phone it fills the width. The copy shown on load uses logical positions, so it is at the end edge on its own.
What is checked, and how is a failed save shown?
The name can't be empty, and the quantity and reorder level must be whole numbers, up to 999 and 200. The checks run when you save, not while you type. A failed save keeps you where you are, takes the place of the hint at the top with a sentence such as "Fix 2 fields to save: Name, Reorder level", marks each field with its own problem under it, and moves focus to the first one. The summary links are real buttons, so each one focuses its field.
How do I move between items, and why is it sometimes refused?
With the previous and next buttons or with Save and next. The two arrows are quiet while the form has unsaved changes, and pressing one says "Save or reset first" in the polite status message, so an edit is never lost by a click. On the last item the main button reads "Save and close". Moving puts focus in the Name field of the next item, and the table behind the sheet redraws the saved row.
What stays local, and how do I wire a real save?
The eight items are typed in ITEMS and saved into local state; the table behind the sheet is drawn from that state, and a reload restores the originals. Nothing is sent. In your app post the item in the save handler, show the server's refusal on the field it names, and update the row from the response; keep the previous and next guard so an unsaved edit is not dropped.
Is it accessible from the keyboard?
Yes. The real sheet is named by its title and described by its sentence, focus starts in the Name field and stays inside until it closes, and Escape and the close button return focus to Edit items. The trigger is passed to SheetTrigger through render, and the sheet is controlled with open and onOpenChange. Ctrl or Command with Enter saves from any field. The copy shown on load moves no focus; Escape inside it and its close button close it and put focus on Edit items.
Related
- Pro
Edit Profile Dialog
Account and securityA community profile page with its edit dialog shown open: a display name, a username checked against the names already taken, a main craft you type or pick, a bio with a 160 character count, and a strip of chips that says what changed.
- Pro
Filter Sort Dialog
Side sheetsA vinyl shop's records page with its filter panel shown open as a sheet from the start edge: genre chips, a decade list, a two-thumb price range, conditions, an in-stock switch and a sort order, all changing the grid behind it as you touch them.
- Pro
Version History Dialog
Side sheetsA docs tool's version history sheet shown open: six versions with authors and times, the diff of the chosen one against the current text marked with underline, strike-through, glyphs and words, and a two-step restore.
- Pro
Assign Task Dialog
Side sheetsA sprint board with a side sheet that assigns its one unowned task shown open: five people with their open tasks and load, a priority, a due date from chips or an inline calendar, and a switch to notify the assignee.
- Pro
Profile Drawer Team
Lists and directoriesEight people of a design agency as rows that each open one side drawer with a quote, a bio and three career figures, with Previous and Next buttons that step through the team without closing the drawer.
- Pro
Reorder Items Dialog
Notes and editingA landing-page builder's reorder dialog shown open: five page sections with grips you lift with Space and move with the arrow keys, Move up and down buttons, a spoken position, and the page behind it rearranging on save.