One group of a settings page: a title and description beside its fields.
$ pnpm dlx shadcn@latest add @dashral/form-sectionInstallation
$ pnpm dlx shadcn@latest add @dashral/form-sectionAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/form-section.json
Usage
import { Button } from "@/components/dashral/button"
import { Input } from "@/components/dashral/input"
import { FormSection } from "@/components/dashral/form-section"
<FormSection title="Profile" description="How you appear to your team." footer={<Button type="submit">Save</Button>}>
<Input label="Name" defaultValue={user.name} />
<Input label="Email" type="email" defaultValue={user.email} />
</FormSection>Using the npm package? Import from @dashral/ui/components/form-section instead, here and in the examples; the rest is the same.
Examples
Settings page
variant="card" with a Save bar per section, divided, ending in a danger zone.
API reference
FormSection
Also takes every prop of <section>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
title | ReactNodeWhat the fields are about. Required. | — |
description | ReactNodeWhat changing them does. | — |
titleAs | "h2" | "h3"The heading's level. | "h2" |
children | ReactNodeThe fields. Required. | — |
footer | ReactNodeThe section's buttons; a bar along the foot of a card. | — |
layout | "split" | "stacked"The title beside the fields from the md breakpoint, or above them. | "split" |
variant | "plain" | "card"The fields on the page, or in a bordered card. | "plain" |
divided | booleanA line above, to part it from the section before. | false |
classNames | { header, title, description, content, footer }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Accessibility
- A <section> named by its heading (aria-labelledby), so it's a region screen readers can jump to.
- It doesn't make a form: wrap the sections in one, or each in its own.