forms

Builds validated React forms using TanStack Form with pre-bound field components.

10|3|Updated Oct 23, 2023
One-click install
npx skills add https://github.com/Layer-Fi/layer-react --skill forms-layer-fi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: forms
Source: https://github.com/Layer-Fi/layer-react/tree/main/src/components/blocks/Form
Command: npx skills add https://github.com/Layer-Fi/layer-react --skill forms-layer-fi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-form, react-aria-components, effect, react-i18next, classnames.

What problem does it solve? Building forms in React often means manually wiring inputs to state, labels, validation, and error display. This Skill standardizes form construction in the Layer component library so every field gets label association, ARIA invalid state, error rendering, and read-only handling automatically through TanStack Form. ## Core Features & Use Cases - Pre-bound field components: useAppForm exposes FormTextField, FormNumberField, FormDatePickerField, FormNonRecursiveBigDecimalField, FormCheckboxField, FormSwitchField, FormRadioGroupField, and more via form.AppField, so no raw <Input> plus useState wiring is needed. - Validation and error layers: Per-field validators keyed by trigger (onChange, onBlur, onSubmit) return translated messages, shared validators live in @utils/shared/form/validators, and form-level API failures render through FormErrorBanner. - Use Case: Build a chart-of-accounts form by writing a useThingForm hook owning state and submission, then rendering field.FormTextField components with translated labels, and asserting the mutation request body in tests via MSW. ## Quick Start Ask the AI to create a new form following this Skill's pattern: a hook using useAppForm with validators and a presentational component rendering form.AppField fields with translated labels.

Frequently Asked Questions about forms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a form with TanStack Form in React?▼

Create a hook that calls useAppForm with defaultValues and an onSubmit handler, then render fields with form.AppField and the bound field.FormTextField-style components. Read form state with useStore(form.store, selector) selecting narrow slices like isValid or isSubmitting.

How do I add validation to TanStack Form fields?▼

Pass a validators prop on form.AppField keyed by trigger such as onChange, onBlur, or onSubmit. Each validator returns a translated error message on failure and undefined on success; reusable rules like required and notEmpty live in @utils/shared/form/validators.

Why does TanStack Form throw TS2589 type instantiation excessively deep?▼

This happens when form values contain rich class types like BigDecimal. Keep form values as plain data, using NonRecursiveBigDecimal instead of BigDecimal, and pass class instances as props rather than storing them in form values.

How do I add a new field component to useAppForm?▼

Create the component in src/components/blocks/Form/ following CommonFormFieldProps, then register it in the fieldComponents map of createFormHook in useForm.tsx. It is not available on the field object until registered there.

How do I test forms built with TanStack Form?▼

Use the form filler utilities, addressing fields by their accessible label, which is why the label prop is required. Assert on the request body captured by the MSW handler's onRequest callback rather than inspecting internal form state.