Form Dialog

A modal dialog that renders a form.

FormDialog can be used to quickly request information from people without leaving the current page.

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.

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#

KeyAction
EnterWhen the dialog is open, submits the form.
EscapeWhen the dialog is open, closes the dialog.
TabFocus next field

Was this helpful?