shadcn.io is not affiliated with official shadcn/ui
Alert Dialog examples · Form
Single Input Dialog Alert Dialog for React
An alert dialog with one prefilled input for renaming a project.
A full form is too much for a rename. This React alert dialog asks for one thing, the project's new name, in an input prefilled with the current one. It's shadcn.io's Alert Dialog on Base UI with an Input in a Field.
Preview
Installation
FAQ
Alert Dialog or Dialog for a rename?
An Alert Dialog suits a quick, committed edit: it stays open until people save or cancel. Use a Dialog for longer forms people may abandon.
Should the input show the current value?
Yes. defaultValue shows the current name, Untitled Project, so people edit rather than retype. Leave it empty for create flows.
Does the input get focus when it opens?
The dialog moves focus inside when it opens. To land on the input, give it autoFocus.
How do I validate the name?
Control the input and disable Save while it's empty or invalid, with a FieldError saying what to fix.
Related
- Multiple Inputs Dialog Alert DialogAn alert dialog with a subject input and
- Standard DialogA share dialog with a read-only link, a
- Form with Validation State Alert DialogAn alert dialog whose input shows an
- Input with LabelA text input with a label above it
- Simple Confirmation Dialog Alert DialogA simple confirmation dialog with Cancel
- Form with Checkboxes Alert DialogAn alert dialog with checkboxes, each