Form shell with sections, zod validation and a save bar; required fields fill a completion ring that becomes the ball Save rolls into a check.
Change the valueChange the value
Suppliers / New supplier
Imported from a CSV. Complete the required fields to create it.
form, lively
Use it for every screen that edits saved data: settings pages, project and store settings, a
bulk-edit drawer, an invite dialog, a one-row alert rule. It is the shadcn Form (react-hook-form
glue with FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage)
plus what that one leaves out: sections, a notion of "unsaved", and an answer to Save. For a
multi-step flow put a Stepper around it; for a single field that saves on blur use Inline Edit.
The moment comes in three beats. Focusing a field charges its section: the section's 1px rim
tints toward ring, and once a value changes the section keeps a ring rim, so you can see what
you edited after you leave it. The first change raises the save bar: a 44px pill rises 12px
into place with "Unsaved changes", Reset and Save cascading in. Pressing Save is the action:
the label pinches into a 20px ball that leaves the button and rolls across the bar to the start
wall. It settles with a squash against that wall and traces a check; the bar says "Saved"
for about two seconds and sinks away. A failed save rolls the ball home, the label returns and
the server message rises in the bar, without a shake.
On a form that creates a record (a new supplier, a payout account, a KYC file) mark the fields
the record cannot exist without as required. Each gets a small primary dot after its label,
each section header counts them ("1/2"), and the save bar stays up from the start with a 20px
ring at its start: one segment per required field, "4 of 7 required" beside it. A field counts
once its value is filled and your schema accepts it, and once you leave it: the arc's end springs
forward by one segment and settles, the numbers roll. Empty a field again and the arc springs back.
When the last one is valid the section tallies turn into checks, the ring fills into the same
ball Save throws, and Save turns primary (it is quiet until then, but always pressable). Press
the ring or its count to jump to the next required field. Settings forms, where every field is
already filled, have no required fields and stay ring-less.
pnpm dlx shadcn@latest add @motionkit-pro/formnpx shadcn@latest add @motionkit-pro/formyarn dlx shadcn@latest add @motionkit-pro/formbunx --bun shadcn@latest add @motionkit-pro/formRequires a Signature license and the @motionkit-pro registry with your token. See Installation.
The form uses react-hook-form; validation is up to you. The examples use zod through
@hookform/resolvers:
npm install zod @hookform/resolversimport { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
FormSection,
} from "@/components/ui/form"
import { TextField } from "@/components/ui/text-field"
const schema = z.object({ workspace: z.string().min(2, "Use at least 2 characters") })
export function WorkspaceSettings() {
const form = useForm({ resolver: zodResolver(schema), defaultValues: { workspace: "" } })
return (
<Form form={form} onSubmit={(values) => saveWorkspace(values)}>
<FormSection title="General" description="Shown to every member.">
<FormField
control={form.control}
name="workspace"
render={({ field }) => (
<FormItem>
<FormLabel>Workspace name</FormLabel>
<FormControl>
<TextField preset="stacked" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</FormSection>
</Form>
)
}onSubmit receives the valid values. Return a promise and the bar follows it: pending rolls the
ball and makes the fields read-only, resolve draws the check and makes the written values the new
baseline, reject shows the error. Throw a FormError to put the message on a field:
import { FormError } from "@/components/ui/form"
async function save(values: Values) {
const response = await fetch("/api/workspace", { method: "PUT", body: JSON.stringify(values) })
if (response.status === 409) throw new FormError("This email is taken", { field: "email" })
if (!response.ok) throw new Error("Could not save. Try again.")
}<Form form={form} onSubmit={createSupplier} saveLabel="Create" onComplete={() => track("ready")}>
<FormSection title="Payout">
<FormField
control={form.control}
name="iban"
required
render={({ field }) => (
<FormItem>
<FormLabel>IBAN</FormLabel>
<FormControl>
<TextField preset="stacked" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</FormSection>
</Form>required on FormField is bookkeeping, not validation: the schema still decides what is
valid, and the ring asks it silently (no message appears before you submit). Optional fields
never move the ring. progressLabel sets the copy ("{done} of {total} required"; {done}
rolls), showProgress={false} hides the ring and tallies, showTally={false} hides one
section's count. <FormProgress /> places the ring and its count anywhere (a page header, the
inline preset), and useFormProgress() returns { done, total, complete, next, focusNext }
for your own UI.
Coming from shadcn, rename the import: the parts have the same names and props. FormControl
works with any field, every MotionKit control included. FormRow puts fields side by side and
stacks them when there is no room for 14rem each. useUnsavedChanges() returns true while the
form is dirty, for your router's leave guard; warnOnLeave (on by default) covers closing or
reloading the tab.
Three presets change the arrangement, not the look: page (default: section tiles, bar sticky at
the bottom of the scroll container), panel (for drawers and dialogs: sections split by dividers,
the bar as the footer, Reset reads Cancel) and inline (one compact section with no bar: place
<FormSubmit /> at the end of the last row and it plays the ball itself, carrying the dirty dot).
density sets the field gap (comfortable 16px, compact 12px). The labels are props
(saveLabel, resetLabel, savedLabel, savingLabel, unsavedLabel). Set
showSaveBar={false} and render <FormSaveBar> yourself to add buttons such as "Save and send".
Prop
Type
Also accepts all props of Omit<ComponentProps<"form">, "onSubmit" | "children">.
Prop
Type
Also accepts all props of Omit<ComponentProps<"div">, "children">.
Prop
Type
Also accepts all props of Omit<ComponentProps<"section">, "title">.
Prop
Type
Also accepts all props of ComponentProps<"div">.
Prop
Type
Also accepts all props of Omit<ComponentProps<"button">, "type" | "children">.
Every field of a settings page is already filled, so it has no required fields and no ring: the bar rises on the first change and Save answers with the ball.
Change the valueChange the value
Changes apply to every member.
form, lively
Change the valueChange the value
#4120, #4123 and #4131 · Help desk
form, lively
Change the valueChange the value
form, lively
The panel preset inside a drawer body: dividers instead of tiles, a compact gap, and a footer
bar with Cancel and Save.
<Form form={form} preset="panel" density="compact" onSubmit={updateTickets}>
<FormSection title="Routing">…</FormSection>
<FormSection title="Labels">…</FormSection>
</Form>The inline preset: one row of fields and a FormSubmit at its end. Submit with the threshold
empty and the rim and the message rise under it; fill it and the button's label rolls into the
check.
<Form form={form} preset="inline" density="compact" onSubmit={saveRule}>
<FormSection title="Threshold alert">
<FormRow>
{/* Metric, operator and threshold fields */}
<FormSubmit>Save rule</FormSubmit>
</FormRow>
</FormSection>
</Form><form>; each FormSection is a <section aria-labelledby> naming it by its title, its
fields inside a <fieldset> so disabled reaches every native control.FormLabel is a Radix label with htmlFor; FormControl sets id, aria-describedby
(description, plus the message when there is one) and aria-invalid on the field.required field's control gets aria-required="true"; the label's dot is aria-hidden.
The ring and the section tallies are aria-hidden drawings with text beside them: the bar's
polite live region says "5 of 7 required" as it changes, each section header has the same
count as screen-reader text. Pressing the count is a real button named "4 of 7 required: go to
the next one"; it focuses the first required field that is not valid yet and never moves focus
on its own.role="alert"; the others are aria-live="polite", so a screen reader hears one error, not a
chorus. After a successful save focus stays where it was.role="region" named "Unsaved changes". Its status ("Unsaved changes",
"Saving…", "Saved", the error) is read from a polite live region; the animated copy, the dirty
dot and the ball are aria-hidden. The dot is never the only cue: the text says it.type="submit" and type="reset" buttons with a 3px ring/50 focus
ring. While saving they are aria-disabled (focus is not lost) and the fields are readOnly,
at full contrast: nothing is dimmed.foreground, descriptions in muted-foreground, errors
in destructive, the ball in primary and primary-foreground, so contrast follows your shadcn
theme in light and dark. The section rim is a box-shadow, never a border, so nothing shifts.| Key | Action |
|---|---|
| Tab / Shift + Tab | Moves through the fields in DOM order; the save bar comes last |
| Enter | In a field, submits the form (while there is a Save button) |
| Escape | Inside the save bar, moves focus to Reset (Cancel in panel) |
| Enter / Space on the count | Focuses the first required field that is not valid yet |
| Space / Enter on Save / Reset | Saves (the ball rolls) or puts every field back to its saved value |
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") nothing is
skipped; only the travel goes. The section rim still tints (it is color only). The save bar fades
in place instead of rising. On Save the label crossfades to a still 20px ball that stays on the
button, and the check fades in on it while the status text changes to "Saving…" and "Saved".
Errors fade in under their fields. Ring segments fade in whole instead of being drawn, with no
overshoot, the closed ring fades into the ball, and the counts crossfade. The still result is a finished form with a labelled bar.
:focus-within and :has([data-dirty]): no
JavaScript runs between a focus and its tint.transform and opacity only, driven by
motion values, so React does not re-render while the ball rolls. The bar measures its rail once
per resize with a ResizeObserver.motion, react-hook-form,
@radix-ui/react-label and @radix-ui/react-slot (installed with it); zod and
@hookform/resolvers are yours to add for validation.Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-label, @radix-ui/react-slot, motion.
a value change, keyboard focus, press, an app event
The rim still tints; the bar fades in place; ring segments and the closed ball fade in, numbers crossfade; on Save the label crossfades to a still ball and the check fades in on it; errors fade in.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)