One part of a form, with its own save
Form section gives a part of a form its heading and a sentence on what it is for, lays its fields in a grid that folds by the room it has, and ends with its own actions. Set the heading beside the fields and stack a few of them, each under a rule, and you have a settings page.
Two columns of fields
Profile
How you appear to the people you work with.
Settings layout
Notifications
What we email you about.
Alternatives
- Use Widget instead when the section is a dashboard tile rather than part of a form.
Props
Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.
| Prop | Type | Default | Description |
|---|---|---|---|
title* | string | The section's heading.
Note: this shadows the native `title` tooltip attribute, which FormSection does not expose. | |
description | ReactNode | A sentence on what the fields are for or what changing them does. | |
children | ReactNode | The fields, laid out in `columns`. | |
columns | 1 | 2 | 3 | 1 | How many columns the fields run to; they fold to one as the section narrows. |
layout | "aside" | "stacked" | 'stacked' | `stacked` puts the heading above the fields; `aside` sets it in a column beside them, the settings page's layout, stacking when the section is narrow. |
actions | ReactNode | The section's own controls, at the foot of the fields: a Save, a Cancel. | |
headingLevel | 2 | 4 | 3 | 2 | The heading's place in the outline. Defaults to 2, a section of a page. |
divider | boolean | false | Draws a rule above the section, for a column of sections. |
className | string | '' | Additional CSS classes |
Keys
It holds the fields and actions passed in, each a native control reached with Tab. Those keys belong to the platform, so no test of this library presses them.
// From the npm package
import { FormSection } from 'rift-ds/components/FormSection/FormSection';
// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/form-section.json1.1 kB gzipped, with everything it imports. Peer dependencies are not counted.
For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.