Field group
Fields or options that answer one question, under one legend, with one error.
Installation
npm i @uisatin/uiimport { FieldGroup } from '@uisatin/ui/field-group'About 10.5 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/field-group.json https://uisatin.dev/r/switch.jsonAdds field-group.tsx, form-field.tsx and switch.tsx to components/ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The FieldGroup component is a fieldset with a legend, a description and one error for fields or options that answer one question.
| Prop | Type | Default |
|---|---|---|
legend | ReactNode | — |
variant | "fields""choices" | "fields" |
columns | 123 | 1 |
layout | "vertical""horizontal" | "vertical" |
description | ReactNode | — |
error | ReactNode | — |
name | string | — |
required | boolean | false |
disabled | boolean | false |
className | string | — |
ref | Ref<HTMLFieldSetElement> | — |
...props | ComponentProps<'fieldset'>Other attributes go to <fieldset> | — |
Accessibility
A native fieldset: the legend names the whole group for screen readers, and disabled reaches every control in it. The description and the error are linked with aria-describedby. The required mark is hidden, so set required on the controls too. After a submit with errors, Form focuses the first control of an invalid group, in document order with the other fields.
Something wrong or missing on this page?
Report a problemSuggest an improvement