tanstack-form
Skill0 starsChanged 4 months agoMITView on GitHub
How to build forms using TanStack Form v1 with the shared useAppForm hook and App* field components. Use this whenever creating or modifying any form — create forms, update/edit forms, filter forms, or modal forms. Covers form setup, field components, Zod schema validation, form sections pattern, submit handling with confirmation dialogs, and filter forms that sync with URL.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- heryTz/skillstheir own version, first seen Oct 13, 2026
- prdlk/skillstheir own version, first seen Oct 11, 2026
- Kiranism/next-shadcn-dashboard-startertheir own version, first seen Oct 8, 2026
- dvaJi/argostheir own version, first seen Sep 9, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- Kiranism/next-shadcn-dashboard-starter★ 7.2ksame name
- dvaJi/argos★ 3same name
- heryTz/skills★ 1same name
- prdlk/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- feature-architectureSkill
- frontend-auditSkill
- frontend-i18nSkill
- mui-themeSkill
- react-coreSkill
- react-standardSkill
- table-mrtSkill
- tanstack-querySkill
- tanstack-routerSkill
- flutter-clean-arch-getxSkill
- flutter-flavorsSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Always use useAppForm, don't use useApp.
- Very specific: line 13
Every form's DOM scope is <form.AppForm> wrapping a <form> element with
- Very specific: line 14
Always render the submit action via <form.SubmitButton> — never a raw MUI <Button type="submit">.
- Distinctive: line 18
Read the relevant file when you need it:
- Very specific: line 86
All accessed via field.ComponentName inside form.AppField:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Forms with TanStack Form
The project uses TanStack Form v1 with a shared useAppForm hook that pre-binds all form components. Always use this hook rather than raw useForm.
Core Invariants (always enforced — never violate)
- Always use
useAppForm, don't useuseApp. - Every form's DOM scope is
<form.AppForm>wrapping a<form>element withonSubmit={(e) => { e.preventDefault(); form.handleSubmit() }}(the existing<Box component="form">examples already satisfy this — no code changes needed there, this just makes the structural rule explicit). - Always render the submit action via
<form.SubmitButton>— never a raw MUI<Button type="submit">.
References
Read the relevant file when you need it:
references/form-composition.md—withForm,withFieldGroup,useTypedAppFormContextfor multi-section or nested-object formsreferences/focus-management.md—createOnSubmitInvalidFocusHandler,focusFirstInvalidField, how it worksreferences/filter-forms.md— URL-synced filter forms (Accordion + search params) + reactive/cascading fields
Imports
import { useAppForm, withForm, withFieldGroup, useTypedAppFormContext } from '@/shared/components/form'
import { createOnSubmitInvalidFocusHandler } from '@/shared/components/form'Basic Form Setup
export function FeatureForm() {
const { t } = useTranslation()
const formRef = useRef<HTMLFormElement>(null)
const form = useAppForm({
defaultValues: {
name: '' as string,
count: 0,
category_id: null as number | null,
},
validators: { onChange: yourZodSchema },
onSubmitInvalid: createOnSubmitInvalidFocusHandler(() => formRef.current),
onSubmit: async ({ value }) => {
await mutation.mutateAsync(value)
},
})
return (
<form.AppForm>
<Box
component="form"
ref={formRef}
onSubmit={(e) => { e.preventDefault(); form.handleSubmit() }}
noValidate
>
<form.AppField name="name">
{(field) => <field.TextField label={t('feature.name')} required />}
</form.AppField>
<form.AppField name="count">
{(field) => <field.TextFieldNumber label={t('feature.count')} />}
</form.AppField>
<form.SubmitButton
label={t('common.save')}
loading={mutation.isPending}
/>
</Box>
</form.AppForm>
)
}form.SubmitButton renders MUI's native loading prop under the hood — this shows a CircularProgress spinner and auto-disables the button; no separate loadingLabel text-swap is needed.
Available Field Components
All accessed via field.ComponentName inside form.AppField:
| Component | Use for |
field.TextField | Text input |
field.TextFieldNumber | Numeric input |
field.Select | Dropdown with options: { value, label }[] |
field.Autocomplete | Searchable dropdown |
field.AutocompleteInfinite | Paginated searchable dropdown |
field.DatePicker | Date picker (Day.js) |
field.DateTimePicker | Date + time picker |
field.Checkbox | Boolean checkbox |
field.Switch | Toggle switch |
field.ImageUploadField | File upload |
TextField
<form.AppField name="description">
{(field) => (
<field.TextField label="Description" required multiline rows={4} placeholder="Enter..." />
)}
</form.AppField>Select
<form.AppField name="status">
{(field) => (
<field.Select
label={t('feature.status')}
options={STATUS_OPTIONS.map(opt => ({ value: opt.value, label: t(opt.label) }))}
clearable
/>
)}
</form.AppField>Autocomplete
<form.AppField name="category_id">
{(field) => (
<field.Autocomplete
label={t('feature.category')}
options={categories}
getOptionLabel={(opt) => opt.name}
getOptionValue={(opt) => opt.id}
multiple={false}
/>
)}
</form.AppField>Zod Schema with Translation
Schemas needing translated error messages are factory functions accepting t: TFunction:
import { z } from 'zod'
import type { TFunction } from 'i18next'
import { formOptions } from '@tanstack/react-form'
export const getFeatureCreateSchema = (t: TFunction) => z.object({
name: z.string().min(1, t('feature.validation.nameRequired')).max(255),
count: z.number().min(0),
category_id: z.number().min(1, t('feature.validation.categoryRequired')),
notes: z.string().nullable(),
})
export type FeatureCreateFormData = z.infer<ReturnType<typeof getFeatureCreateSchema>>
export const featureCreateFormOption = formOptions({
defaultValues: {
name: '',
count: 0,
category_id: null as number | null,
notes: null as string | null,
},
})Usage:
const schema = getFeatureCreateSchema(t)
const form = useAppForm({
defaultValues: featureCreateFormOption.defaultValues,
validators: { onChange: schema },
})Submit with Confirmation Dialog
const { confirm } = useConfirmDialog()
const form = useAppForm({
onSubmit: async () => {
const confirmed = await confirm({
title: t('feature.confirmUpdate'),
message: t('feature.confirmUpdateMessage'),
confirmText: t('common.save'),
cancelText: t('common.cancel'),
confirmColor: 'primary',
maxWidth: 'xs',
})
if (!confirmed) return
mutation.mutate(form.state.values, {
onSuccess: () => {
showSuccess(t('feature.updateSuccess'))
navigate({ to: '/feature/$featureId', params: { featureId: String(id) } })
},
onError: (error) => showError(translateError(error)),
})
},
})Sticky Footer Submit Bar
<Box
sx={{
position: 'sticky', bottom: 0,
bgcolor: 'background.paper',
borderTop: '1px solid', borderColor: 'divider',
p: 2, mt: 3, mx: -2,
}}
>
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} justifyContent="flex-end">
<Button variant="outlined" onClick={() => navigate({ to: '..' })}>
{t('common.cancel')}
</Button>
<form.SubmitButton
label={t('common.save')}
loading={mutation.isPending}
/>
</Stack>
</Box>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

