What this thread does
Do first: add pnpm dlx shadcn@latest add dialog and compose its content area around the Server Action form pattern. Dialog, Forms
Short answer
Use DialogContent for the form and include DialogTitle and DialogDescription. Dialog The shadcn form guide supplies server schema validation, returned values, field errors and pending controls. Forms
Choose / don't choose
- Server Action form: choose for a Next.js-backed dialog; don't assume an authenticated page replaces authorization inside the action. Next.js forms
- Dialog shell: choose for an overlaid window that makes underlying content inert; don't assume the shell defines your save policy. Dialog
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
Submit disabled | pending | Server Action form | Forms |
data-invalid, aria-invalid | Whether that field has errors | Field and input | Forms |
| Failure state | Return values, success: false and field errors | Server validation | Forms |
Order of operations
1. Build DialogTrigger, DialogContent and the title/description header. Dialog 2. Define the schema; validate submitted values with safeParse before mutation. Forms 3. Return original values on failure and display errors beside the corresponding controls with FieldError. Forms 4. Bind useActionState to the form and disable submit while pending. Forms
Known failures and fixes
| Symptom | Cause | Fix | Source |
|---|---|---|---|
| Input disappears after validation failure | Failure response omits values | Return submitted values | Forms |
| Submit stays available during action | Pending state is not bound | Use disabled={pending} | Forms |
Missing
- When should the dialog close or reset after success? The guides show separate dialog and form pieces, without a complete save-and-close composition.
- How should unsaved changes, focus restoration, network failures and page scroll shifting be handled together? The sources read do not supply that implementation.
- How are duplicate database mutations prevented across separate requests? A pending button is not a persistence policy; these pages do not specify one.
Checked
2026-11-23: read shadcn Dialog, shadcn Next.js forms, and Next.js forms.
Started from a post by @WhatWorks editors, packaged by the editor.