/mantine:mantine-formfrom mantine
Builds forms with @mantine/form: useForm setup, validation rules (zod, valibot, arktype), nested/array fields, form state reading, form context splitting, custom inputs, and the useField hook.
Ships in mantine. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Written for Mantine 10.x. Upgrading code written for 9.x: see Coming from 9.x.
import { isEmail, isInRange, useForm } from '@mantine/form';
interface ProfileValues {
email: string;
age: number | string;
}
const form = useForm<ProfileValues>({
initialValues: {
email: '',
age: '',
},
validate: {
email: isEmail('Invalid email'),
age: isInRange({ min: 18 }, 'Must be at least 18'),
},
});
The form is uncontrolled by default: values live outside React state, typing rerenders only
the input, not the component that calls useForm. Do not write mode: 'uncontrolled'. Set
mode: 'controlled' only for a small form that renders form.values directly.
Give every form a name in kebab-case (useForm({ name: 'job-application', ... })): it
prefixes the data-path attributes and lets createFormActions(name) control the form from
outside.
Give every field rendered with an input an initial value ('', null, false, []), otherwise
React warns about an input switching from uncontrolled to controlled. NumberInput uses
number | string with '' for empty, Select and dates inputs use string | null.
<TextInput label="Email" {...form.getInputProps('email')} />
<NumberInput label="Age" allowNegative={false} allowDecimal={false} {...form.getInputProps('age')} />
No key prop is needed: inputs update after setFieldValue, setValues, reset and list handlers.
Checkboxes and switches need { type: 'checkbox' }:
<Checkbox label="I agree" {...form.getInputProps('agreed', { type: 'checkbox' })} />
Select, MultiSelect, TagsInput, NumberInput, Radio.Group, Checkbox.Group, dates inputs
and other Mantine inputs with a value / onChange pair work with plain getInputProps:
<Radio.Group label="Delivery" {...form.getInputProps('delivery')}>
<Group mt="xs">
<Radio value="standard" label="Standard" />
<Radio value="express" label="Express" />
</Group>
</Radio.Group>
Components without an error message prop (Slider, RangeSlider, Rating, SegmentedControl,
Chip.Group, and PinInput, whose error is a boolean) need { withError: false }. Wrap them in
Input.Wrapper to get a label and an error that look like the other inputs. Never render errors
with <Text c="red">:
<Input.Wrapper label="Stock level" error={form.errors.stock}>
<Slider {...form.getInputProps('stock', { withError: false })} />
</Input.Wrapper>
const handleSubmit = async (values: ProfileValues) => {
await saveProfile(values);
notifications.show({ title: 'Profile saved', message: values.email });
};
// Rules object order decides the key order of errors: the first key is the first invalid field
const handleErrors = (errors: FormErrors) => {
form.focusInput(Object.keys(errors)[0]);
};
<form onSubmit={form.onSubmit(handleSubmit, handleErrors)}>
...
<Group justify="flex-end">
<Button type="submit" loading={form.submitting}>
Save
</Button>
</Group>
</form>;
onSubmit calls the handler only when validation passes. form.submitting is true during
async validation and until the promise returned by the handler settles (resolved or rejected).
Catch request errors inside the handler and turn them into form errors, see the server errors
pattern.
One folder per form. <Name>Form.tsx holds useForm, navigation between steps and submission;
each step, tab, section, repeated row or type-specific options block is a component in its own
file that takes form as a prop — a switch that renders different fields per variant is one
file per variant (options/TextOptions.tsx, options/SelectOptions.tsx), not one file with a
switch. types.ts holds the values interface and the form type; validation rules and
constants live in validation.ts. Name the form type after the values, not after the component:
type ProfileFormType = UseFormReturnType<ProfileValues> when the component is ProfileForm. A
file over about 150 lines is a sign to split further. Each component that needs styles has its
own <Name>.module.css; no shared stylesheet for the whole form. A component that has a CSS
module or a test file gets its own folder (SaveBar/SaveBar.tsx, SaveBar/SaveBar.module.css,
SaveBar/SaveBar.test.tsx); single-file components and the plain modules (types.ts,
validation.ts, api.ts) stay at the root of the feature folder. Never a flat list where
X.tsx and X.module.css sit between twenty other files.
See splitting a form into components.
A form built from a schema dispatches per field type through an object keyed by the type, with one
small named function or component per type: const FIELD_RULES: { [T in FieldType]: (field) => Rule } = { text: textRule, json: jsonRule, … } in validation.ts, const FIELD_INPUTS = { text: TextField, … }
for rendering. No switch with the bodies inline: the reader scans the keys, then reads one function.
Comments only where the code cannot explain itself: a workaround, a browser or library behavior
the next reader would not expect (// preventDefault keeps focus in the input so its blur error does not shift the button). No comments that restate what the code does, no JSDoc on internal
helpers.
This skill covers form logic only. Which input to use for a piece of data, placeholders,
button variants, icon actions, cards, modals and spacing are decided by the mantine-ui skill:
read it before writing the markup of a form. Forms in modals open the modal with useModal
(see form in a modal), not with useDisclosure.
Tests are written with the mantine-testing skill: one observable behavior per test, queries by
role and label, render inside MantineProvider with env="test", and the jsdom recipes for
Mantine inputs (picker inputs open a drawer in jsdom and apply the value on Save). The
forms checklist lists what every form test file covers.
validate: {
name: isNotEmpty('Required'),
email: isEmail('Invalid email'),
password: hasLength({ min: 8 }, 'Min 8 characters'),
confirmPassword: matchesField('password', 'Passwords do not match'),
terms: isNotEmpty('You must accept terms'),
companyName: when((values) => values.isCompany, isNotEmpty('Company name is required')),
}
Rules receive (value, values, path, signal), so cross-field and conditional rules read other
fields from values. when(condition, rule) runs rule only when condition(values) returns
true, otherwise the field is valid.
import { z } from 'zod';
import { schemaResolver, useForm } from '@mantine/form';
const schema = z.object({
email: z.email({ error: 'Invalid email' }),
age: z.number({ error: 'Age is required' }).min(18, { error: 'Must be at least 18' }),
});
const form = useForm({
initialValues: { email: '', age: '' as number | '' },
validate: schemaResolver(schema, { sync: true }),
});
schemaResolver is built in, no resolver package is needed. Pass { sync: true } for
synchronous schemas so that form.validate() returns a plain result instead of a Promise.
Async refinements work without it (see the async validation pattern). The schema only validates:
the onSubmit handler receives the form values (or the transformValues result), not the
schema's parsed output. Error keys follow the order of the fields in form values (initialValues),
not the order of the schema issues.
Zod 4 skips object-level refine / superRefine when a field of the object has a type error,
for example null from an empty Select checked with z.string(). Format errors ('' for
z.email()) do not block it. Accept the empty value in the field schema
(z.string().nullable()) and report "required" from the refinement, or use a rules object.
Fields are validated on submit, and submit validation is the right choice for nearly every
field: the user fills the form, presses the button, and sees every problem at once with the
first invalid field focused. An error that appears while the user is still working on the value
("too early validation") is a defect, not a feature: picking a field and switching its unit from
% to a currency, typing the first digits of a price, or tabbing through a date must never show
an error.
The exceptions are rare and specific:
validateInputOnChange: ['username'], // async availability checks only, with validateDebounce
validateInputOnBlur only for a free-text format check on a single-value input that nobody
edits in parts (an email address). Never for numbers, lengths, dates, pin inputs, phone inputs,
value + unit composites or anything with a select next to it: blur happens when the user moves
to the unit select, and the error fires on a half-finished value.bottomSection of a Textarea,
and judge the value on submit.onMouseDown={(event) => event.preventDefault()} to the submit button: the field keeps focus
until the click completes. Not needing this trick is one more reason to validate on submit.The component that calls useForm does not rerender when the user types into a Mantine input
or any input built with useUncontrolled or useFormField. It does rerender when:
form.submitting or form.validating changessetFieldValue, setValues, reset, resetField, initialize, list handlers<input>, a third-party component)Consequences:
form.useWatchValue(path), it rerenders the calling component when
that field changes. form.getValues() and form.values in render do not subscribe and go stale
as the user types. Read the current values with form.getValues() in handlers.form.useDirty(path?) and form.useTouched(path?).
form.isDirty() and form.isTouched() are for handlers only.form.errors, form.submitting, form.validating and form.isValidating(path) are safe in render.form.getValues().items.map(...) is correct: list handlers rerender.const shipsInternationally = form.useWatchValue('shipsInternationally');
const dirty = form.useDirty();
<Button type="submit" disabled={!dirty}>
Save
</Button>;
Bind each field path to a single input. A native <input> that shares a path with a Mantine input
is not updated while the user types in the Mantine input.
mode: 'uncontrolled' (default now) and every key={form.key(path)}. form.key,
useField().key and the Key type no longer exist. List rows use a stable id stored in the item.form.values in render: replace the reads with
form.useWatchValue(path), or set mode: 'controlled' to keep the 9.x behaviour.getInputProps returns value / checked in both modes. Custom inputs and
enhanceGetInputProps functions that read defaultValue must read value.form.isDirty() / form.isTouched() in render with form.useDirty() / form.useTouched().form.setValues clears only the errors of the fields it sets: call form.clearErrors() first
if all errors must go.form.getValues().key now reset in the
onExternalWrite callback of useFormField.UseFieldReturnType takes two type arguments: UseFieldReturnType<string, 'input', 'uncontrolled'>
becomes UseFieldReturnType<string, 'input'>.ClearFieldDirty, SetFieldTouched, SetFieldDirty and SetCalculatedFieldDirty types are
removed: use indexed form types instead, for example UseFormReturnType<Values>['setTouched'].For anything beyond a basic form, read the references before writing code. patterns.md is long:
read its table of contents and every section that matches the task.
references/patterns.md — read for: async validation with loading and success states, focusing and summarizing errors, validation triggers per field type, conditional fields and sections, generated and dependent fields, totals, copying one group of fields to another, select-all checkboxes, list fields (minimum items, tables, reordering, nested lists, array values), multi-step forms, tabs and accordions with errors, dirty state (save bars, per-field reset, unsaved changes prompts), loading and saving records, autosave, forms in modals, server errors, transformValues, splitting a form into components, reusable field components across forms, controlling a form from outside, custom inputs with useFormField, rich text editors, OTP inputs, standalone useFieldreferences/api.md — read for everything else. It is the only place that lists every useForm option and return member (watch, onValuesChange, enhanceGetInputProps, cascadeUpdates, touchTrigger, getField and others), plus useField, useFormField, createFormContext, createFormActions, schemaResolver, built-in validators and typesIf the references do not cover what you need, do not guess:
@mantine/mcp-server) is connected, use search_docs and get_item_dochttps://mantine.dev/llms.txt and open the linked form pageshttps://mantine.dev/form/examples/<Id> (for example LoginForm,
InvoiceItems, EditableTable, StepperWizard, CustomInputSubscription)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub mantinedev/skills --plugin mantine9 skills in this plugin
/mantine-calendarBuild custom calendars and date pickers with @mantine/dates: per-day content and states, your own selection rules, custom periods and display-only calendars. Use this skill when: (1) a calendar shows data per day (prices, free slots, event dots, activity heatmap), (2) days are unavailable with a reason, or a range must not cross booked days, (3) the selection is not a plain date, dates or range (stays, fixed-length periods, fiscal quarters, week or custom-period pickers), (4) a calendar sits next to time slots, presets or a toolbar, or (5) any task involving Calendar, useCalendar, getDayProps, renderDay, excludeDate, getMonthControlProps, Month, Day, CalendarHeader or PickerControl.
/mantine-comboboxBuild custom dropdown/select/autocomplete/multiselect components using Mantine's Combobox primitives. Use this skill when: (1) creating a new custom select-like component with Combobox primitives, (2) building a searchable dropdown, (3) implementing a multi-select or tags input variant, (4) customizing option rendering, (5) adding custom filtering logic, or (6) any task involving useCombobox, Combobox.Target, Combobox.Option, or Combobox.Dropdown.
/mantine-custom-componentsBuild custom components that integrate with Mantine's theming, Styles API, and core features. Use this skill when: (1) creating a new component using factory(), polymorphicFactory(), or genericFactory(), (2) adding Styles API support (classNames, styles, vars, unstyled), (3) implementing CSS variables via createVarsResolver, (4) building compound components with sub-components and shared context, (5) registering a component with MantineProvider via Component.extend(), or (6) any task involving Factory, useProps, useStyles, BoxProps, StylesApiProps, or ElementProps in @mantine/core.
Other plugins' skills for the same job