Usage
import { FormPage } from './FormPage.jsx'
// Edit an existing record in one column, or create a new one in steps with a review:
<FormPage
locale="en"
mode={project ? 'single' : 'steps'}
initialValues={project ?? undefined} // { name, client, description, start, due, amount, billing }
// Optional: the same fields for another record, renamed one key at a time.
fields={{ name: { label: 'Roast name', placeholder: 'e.g. Ethiopia Guji' }, client: { label: 'Origin', placeholder: 'Choose an origin' } }}
groups={{ budget: { title: 'Price', hint: 'Per bag, before tax.' } }}
clients={[{ value: 'eth', label: 'Ethiopia' }, { value: 'col', label: 'Colombia' }]}
billingOptions={[{ value: 'bag', label: 'Per bag' }, { value: 'sub', label: 'Subscription' }]}
currencySign="€"
onSubmit={async (values) => {
const response = await fetch('/api/projects', { method: 'POST', body: JSON.stringify(values) })
return response.ok // false keeps every value and shows "Couldn't save"
}}
onCancel={() => router.back()}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | Language of the built-in text and sample data. |
mode | 'single' | 'steps' | 'single' | One column in groups, or one group per step and a review at the end. |
initialValues | object | — | The record’s current values. Reset returns to the last saved ones. |
fields | { [id]: { label?, placeholder?, hint?, required? } } | — | Renames fields one key at a time over the built-in words; ids are name, client, description, start, due, amount and billing. |
groups | { basics | schedule | budget: { title?, hint? } } | — | Renames the three groups (and steps) one key at a time. |
clients | Array<{ value, label }> | sample clients | The options of the `client` chooser. |
billingOptions | Array<{ value, label, description? }> | fixed, hourly | The cards of the `billing` choice; a new record starts on the first. |
currencySign | string | by locale | The sign in front of the amount, for example €. |
loading / error | boolean | — | Show placeholders while the record loads; show that the last save failed, with a retry. |
onSubmit | (values) => Promise<boolean | void> | — | Save was pressed and every field is valid. Resolve false (or throw) when the save failed. |
onCancel | () => void | — | Cancel was pressed. |
labels | object | — | Replaces any built-in text (keys as in copy.js). |
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.
FormPage.jsxform-page.csscopy.jskit.jsxkit.cssui/base-button/ui/alert-banner/ui/radio-group/ui/select/ui/text-input/ui/textarea/ui/skeleton-shimmer/ui/step-progress/tokens.cssREADME.md
The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.