Create and edit forms
Components: Dialog, Drawer, Field, Input, Textarea, Timeline, Stepper, Button
Form size picks the container.
When to use
- Edit uses the same container as create.
- There is no
Form,FormDialog,FormDrawer,Wizard, verticalStepperor form-level validation component.
Rules
Container and layout
- Wrap body and footer (or the whole
Stepper) in<form className='flex min-h-0 flex-1 flex-col'>so Enter submits. - Size with
width(400 to 1130):Dialog560 default, 400/960 presets;Drawer640 default,700for Timeline forms. There is nosizeprop or exported size constant. - Bodies own their padding. Never add
p-*,px-*orpy-*around their content. - Never pass
classNametoDrawerHeader,DrawerBody,DrawerFooter, theirDialog*aliases, orField. Size the control or grid cell instead. - Never add a close X; the header has one.
- Space fields with
<VStack gap={24}>in a dialog and<VStack gap={12}>in a drawer section. NotFieldGroup(fixed 16px). There is nogapprop onFieldorTimelineContent. - Never style
FieldGroup,FieldLabelorFieldDescriptionwithclassName; it is ignored. - Add
className='py-16'toStepperContent. - If two related fields are short (name and ID, port and protocol), put them in
grid grid-cols-2 gap-12. URLs, secrets and free text get full width. - Number
Timelinesections inTimelineIndicator; title them with a noun phrase. StepperwrapsDrawerBodyandDrawerFooter; its Prev/Next triggers work only inside it. Give itclassName='flex min-h-0 flex-1 flex-col'.- Inside
Stepper:StepperList aria-label='…'(oneStepperItem index statusper step), thenDrawerBodyholding oneStepperContent indexper step, thenDrawerFooter. - Max 6
Steppersteps. Vertical numbered sections are aTimeline, even if Figma says "stepper".
Fields
- Wrap every control in
Field; never a bare<label>. - Order the parts:
FieldLabel(withFieldIndicator),FieldDescription, control,FieldError. - Put
requiredonFieldandFieldIndicatorin every label (*or "(Optional)"). Never type "(optional)" yourself. - Pass
erroranddisabledto the control itself.Field invalidandField disableddo not reachInputorTextarea. - One helper line at most, stating the consequence.
- Show the provider icon in the select option and trigger.
Buttons and copy
- Submit is the default primary
Button type='submit', last on the right. Cancel isvariant='ghost' color='neutral'inDialogClose/DrawerClose asChild. - Omit
sizeon footer buttons. - Never put submit in the header or add a second primary.
- Stepper footer: Cancel left; Back (
variant='outline' color='neutral') and Next right. Back disables itself on step 1; don't wiredisabled. - On the last step, render submit instead of
StepperNextTrigger(disabled there).
Behavior
- Call
event.preventDefault(). Close only after success. - Edit: prefill fields; disable submit until a change.
- Show
FieldErroronly after blur or submit. Steppernever blocks steps. Setstatus='danger'on steps with errors,'completed'on valid ones. There is nolinear,isStepValidororientationprop.
Examples
A dialog form with a 24px field stack.
Submit stays disabled until the required fields are filled, the email error shows only after blur or submit, and a successful request closes the dialog, then shows a toast.
An invalid field: error goes on the control, FieldError renders only while invalid.
Shown after blur: the description stays above the control, the error line below it.
Edit reuses the create container. A field fixed after create is disabled, with a tooltip on a wrapping span.
Fields are prefilled, and "Save changes" stays disabled until a value changes.
Numbered Timeline sections, each a 12px field stack, inside a Drawer width={700} body.
Short related fields share a two-column row; URLs and secrets get full width. "Test
connection" reports in its section with an Alert, never a toast.
A Stepper wrapping body and footer; submit replaces Next on the last step.
Cancel sits left, Back and Next right. Steps never block: a step left with empty required
fields turns danger, a filled one completed.
States
What your app owns
- Values, validation, touched/dirty state, the request and server errors.
- Values across close: containers unmount content, so lift state out.
- The unsaved-changes guard: intercept
onOpenChange(false). - Current step and statuses (
step,onStepChange,status). - Focusing the first invalid field after submit.
- The toast:
useToastfrom@wallarm-org/design-system/Toast, oneToasterat the root. - A live preview (SSO "Continue with …"): build it from
Buttonin agrid grid-cols-2 gap-12row.
FieldIndicator, Dialog* and useToast import from subpaths. Where the Stepper story differs, follow this page.
Related
- Confirmation dialogs: unsaved-changes guard.
- Feedback toasts: success toast.
- Detail drawer: opens the edit form.
- Settings page
- Spacing
- Layering: a
Dialoginside aDrawer.