Form
Lays out fields, groups and sections, hands them errors by name and focuses the first one.
Installation
npm i @uisatin/uiimport { Form, FormSection, FormActions } from '@uisatin/ui/form'About 10.4 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/form.json https://uisatin.dev/r/field-group.json https://uisatin.dev/r/input.json https://uisatin.dev/r/select.json https://uisatin.dev/r/textarea.json https://uisatin.dev/r/checkbox.json https://uisatin.dev/r/button.jsonAdds form.tsx, button.tsx, checkbox.tsx, dropdown.tsx, field-group.tsx, form-field.tsx, input.tsx, kbd.tsx, labels.tsx, pointer-modality.tsx, select.tsx, spinner.tsx and textarea.tsx to components/ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The Form component is a wrapper around the form element that lays out FormFields, FieldGroups, FormSections and FormActions, gives them one layout, hands each its error by name and focuses the first invalid control after a submit.
| Prop | Type | Default |
|---|---|---|
layout | "vertical""horizontal" | "vertical" |
errors | Record<string, ReactNode> | — |
disabled | boolean | false |
onSubmitValues | (values, event) => void | — |
noValidate | boolean | true |
className | string | — |
ref | Ref<HTMLFormElement> | — |
...props | ComponentProps<'form'>Other attributes go to <form> | — |
Accessibility
A native form with noValidate on by default, so your own messages replace the browser’s. After a submit, when errors appear, focus moves to the first control with aria-invalid="true", so keyboard and screen-reader users land on what needs fixing. Messages from errors reach each field by name. disabled wraps the fields in a native fieldset, which disables every control inside. FormSection is a section labelled by its h3 title.
Something wrong or missing on this page?
Report a problemSuggest an improvement