Form Dialog
A modal dialog that renders a form.
FormDialog
can be used to quickly request information from people without leaving the current page.
Source
@saas-ui/modals
- 2.11.4 (latest)
Import#
import { FormDialog } from '@saas-ui/react'
Best practises#
Do
- Use FormDialog for simple forms to increase productivity.
- Set focus on the first field.
Don't
- Use more than 4/5 fields in a dialog.
Usage#
Focus first field#
Use initialFocusRef
for fields that don't support autoFocus
.
Auto form#
When you don't pass any children and supply a schema, the fields will be auto rendered.
Custom footer#
ZodFormDialog#
To use Zod schemas, you can import FormDialog
from @saas-ui/modals/zod
.
YupFormDialog#
To use Yup schemas, you can import FormDialog
from @saas-ui/modals/yup
.
Accessibility#
Keyboard Interaction#
Key | Action |
---|---|
Enter | When the dialog is open, submits the form. |
Escape | When the dialog is open, closes the dialog. |
Tab | Focus next field |
Was this helpful?