Form workflow
Connects input, validation, server errors, and pending and success states.
Preview
Local preview. It doesn't affect real accounts, environments, or run data.
Complete each response by hand below to inspect every submission state. No environment is created.
Preview requests started: 0. The product owns request transport, permissions, and idempotency.
Usage
Connect validation, pending submission, field errors, request failures, restricted access, and success with Form, Field, Fieldset, and messages. Keep input values in controlled state. Describe the result with the values copied at submit time. The example settles the response manually. Use Complete preview request to inspect each state.
- Don't hide service calls or permission policies inside primitives. Keep them in the product.
- Don't present errors as an empty success. Show field errors, request failures, and restricted access as their own states.
- Don't promise that canceling rolls back the server. Canceling stops the request and preserves the draft.
- Don't rely on client checks alone. The product API also needs server validation, permission checks, idempotency, and duplicate-request prevention.
- The example simulates restoring access locally.
Anatomy
Preview response control → result message → named Form → Fieldset(Fields + errors) + submit/reset actions → pending request controls
Keyboard and accessibility
- Base UI Form runs pre-submit validation and focuses the first invalid input.
- While pending, duplicate submissions are blocked and focus moves to Cancel.
- Server field errors map to fields through Field.name keys in errors. A field error moves focus to its input, a request error to Retry, and success to the result heading.
- Canceling or resetting returns focus to the name input.
- Field links each description and error to its control. Color never carries meaning alone.
Give each control a name that describes its purpose. Connect error messages to their controls, and signal state with more than color. Automated checks don't replace manual keyboard and assistive technology testing.
Example code
Shared components take their styles from design tokens. Each example sets its own composition and accessibility attributes. The calling screen defines callbacks, refs, and product data.
Key API
The table lists the common wrapper's main props. See the package type declarations for the full types.