#063
Submit state
Form with a schema that simulates a 1.2 second submit, then shows a success message and resets.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Submit state" pattern (@codeatlasdev/ui demo #063, inputs/use-form) in my app.
Call get_demo({ ids: ["#063"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Create or edit forms that show a loading state while saving.
Keep these library parts, with the props and tokens the demo uses:
- Button, TextArea, TextField, useForm from "@codeatlasdev/ui"
Behaviour to keep:
- `useForm(` with `schema: (data) => {` requires a non-empty title
- `submit()` calls `form.validate()`, sets `form.submitting = true`, waits `setTimeout(r, 1200)`, then `form.reset()`
- TextField Title and TextArea Notes use `disabled={form.submitting}`
- Submit button uses `loading={form.submitting}`, label is `{form.submitting ? 'Saving…' : 'Submit'}`
- Success text renders in `<p class="hint hint--success" role="status">`
- Reset button has `variant="outlined"` and clears `result`
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
How it is built
- `useForm(` with `schema: (data) => {` requires a non-empty title
- `submit()` calls `form.validate()`, sets `form.submitting = true`, waits `setTimeout(r, 1200)`, then `form.reset()`
- TextField Title and TextArea Notes use `disabled={form.submitting}`
- Submit button uses `loading={form.submitting}`, label is `{form.submitting ? 'Saving…' : 'Submit'}`
- Success text renders in `<p class="hint hint--success" role="status">`
- Reset button has `variant="outlined"` and clears `result`
Related
Loading source.