Creating and editing

A form that adds or changes a record: where it opens, its fields, saving, and leaving with unsaved edits.

When it applies

  • Someone adds a record or changes its details in a form.
  • A long form, or a record read beside the page, opens in a Drawer. A short task that holds the page until it is done opens in a Dialog.

Components

What makes the pattern. Each component's own page has its examples and props.

ComponentWhat it does here
DrawerThe panel a long form opens in.
DialogA short edit, and the Discard changes? question.
FieldEvery control's label, hint and error.
InputOne line of text.
TextareaSeveral lines, like a note.
SelectOne value from a list a person can scan.
Date InputA date known by heart, like a date of birth.
Date PickerA date near today, like a due date.
ToastConfirms the save.

Rules

Each comes from AGENTS.md or a component's own best practices, gathered for this job.

GuidancePractice
DoWrap every form control in a Field, so the label names it and the error is announced.
DoUse DateInput for a date people know by heart or read off a document, with max set to today when it can't be in the future. Use DatePicker for a date near today.
DoSet dismissible={false} on the drawer while it holds unsaved edits, and ask Discard changes? in onDismissAttempt.
DoConfirm the save with toast, with a title that says what happened, like "Record saved".
DoStart a control with defaultValue, or hold it with value and onValueChange. Never both.
Don'tUse a Select for two or three options a person compares, like Yes or No. Use RadioGroup or SegmentedControl.
Don'tUse a Dialog for a long form or a whole record. Use Drawer, the CRM's side panel.
Don'tUse a placeholder in place of a label. Every control has a label, or an aria-label where there is no visible text.

See it

  • Form panel: A form in a panel over the list: fields in one column, pairs side by side, and Cancel and Save in the panel's footer.