When to use
Section titled “When to use”Form is the container for every form with several fields that is submitted. It checks fields on submit and stops the submit when there are problems.
When not to use
Section titled “When not to use”- For settings that apply at once: controls such as Switch do not wait for a submit.
- For search: SearchInput handles its own submit.
Anatomy
Section titled “Anatomy”import { Button, Form, TextInput, Provider } from '@bigbang/ui';
export default function Default() { return ( <Provider locale="en-GB"> <Form className="max-w-md"> <TextInput label="Full name" name="name" required autoComplete="name" /> <TextInput label="Email" name="email" type="email" required autoComplete="email" /> <Button type="submit" className="self-start"> Send </Button> </Form> </Provider> );}- Summary: Above the form when a submit stops; a heading and problem links.
- Fields: With their own error messages.
- Submit button:
type="submit".
Behaviour
Section titled “Behaviour”- On submit it gathers server errors in
errors, fields witharia-invalidand browser constraints (required,type="email",pattern). - If there are problems, the submit stops, the summary appears and focus moves to it. The summary enters again on every stopped submit.
- A summary link scrolls the field to the centre of the screen and focuses it.
- With
schema, the form data is checked as an object (a name used more than once becomes a list). Each issue goes to the field named by its path (joined with dots, such asaddress.city); a field’s ownerrorwins. An issue without a path appears in the summary as text without a link. Schema issues join native and server problems in the same summary. - An async schema is awaited; meanwhile the submit button stays focusable but is
aria-disabled, the form isaria-busy, and a second submit is ignored. - Without problems,
onSubmitis called withFormDataand, with a schema, the schema’s output as the third argument. - If
errorschanges after a submit, the summary shows them too.
Guidelines
Section titled “Guidelines”- Show field errors on the field too (
error); the summary is only a guide. - Write error messages as actions: “Enter an email address”, not “Invalid”.
- Do not disable the submit button; users learn what is missing from the summary.
Content
Section titled “Content”| Turkish | English |
|---|---|
| Devam etmek için 1 alanı düzeltin | Fix 1 field to continue |
| Devam etmek için {count} alanı düzeltin | Fix {count} fields to continue |