Cancel and Submit Actions
Field is the forms page: labels, errors, help text, groups, and TanStack Form. Start there for anything inside one field. This recipe covers what goes around the fields: the buttons that end the form, and the sections above them.
Why a recipe, not a component
Each part already exists. Strata lays out the sections, Field wires each control to its label and errors, and Button submits. What joins them is your form: its state, its validation, and the request it sends. A Form component would have to own all three, so mantle leaves the <form> to you.
Sections
- Put the
<form>aroundStrata.Rootand the actions row. The row then sits below the last section, inside the form, where the submit button needs to be. - Give each group of fields that needs its own sentence a
Strata.Section. TheStrata.Titlenames the group, and theStrata.Descriptionsays what its controls do. - Put one
Field.Itemper control inStrata.Body, and stack several in aField.Group. - Give every control its own
Field.Label. AStrata.Titleis a heading, so it names the section and not the control (see Strata accessibility). - Skip Strata for a short form with one group. A
Field.Groupand the actions row below it are enough.
Actions
- End the form with one actions row: Cancel, then the primary button, aligned to the end. The DOM order is the visual order, so the primary button sits on the right and gets focus last.
Dialog.FooterandSheet.Footeruse the same order. - Make the primary button
type="submit"withappearance="filled", and name it for what it does: Create endpoint, not Submit or OK. - Make Cancel
type="button"in your app, and send the person back where they came from. With a router, compose<Button asChild>around itsLink. The demo usestype="reset"because a preview frame has nowhere to go back to. - Set
isLoadingon the primary button while the request runs. It shows a spinner and blocks a second submit, and the label stays the same. - Disable the fields and Cancel while the request runs, so an edit can't land after the values went out. The demo composes
Strata.Rootonto a<fieldset disabled>, which disables every control inside it. - Let the browser check
requiredandtype="url"before your handler runs, and keep the primary button enabled, so a click shows the person what to fix. Show what the server rejects on the field it belongs to, withField.Errors(see Field error messages).
Edit saved settings with a Sandbar
A settings page edits values that already saved. Leave the actions row out, and show a Sandbar while the form has unsaved changes. Its Save changes and Discard buttons replace the actions row, and it stays in view however long the page is.
- Keep
Sandbar.Rootmounted, and set itsopenprop from whether the form differs from what saved. - Render it inside the form, or right after it, so Tab moves from the last field to its buttons.
The Sandbar page has the full form, a failed save, and how to block navigation while changes are unsaved.
Destructive actions
Keep Delete out of the actions row. Give it its own last section, as in the Strata danger zone example, and confirm it with an AlertDialog before it runs. Beside Save, a destructive button is one slip away from the wrong click.