Installation
npx sdaia-ui@latest add form-section
Usage
import { FormSection } from '@/components/ui/FormSection';<FormSection title="Personal information" description="Use the details that appear on your official ID.">
<FieldGroup legend="Full name" layout="horizontal">…</FieldGroup>
</FormSection>RTL
Side by side in Arabic: the title column moves to the right.
Loading demo: form-section-rtl
Examples
Stacked
The title sits above the fields.
Loading demo: form-section-default
Side by side
The title sits in a column next to the fields on wide screens.
Loading demo: form-section-side-by-side
Without description
Turn the description off when the title is enough.
Loading demo: form-section-without-description
Settings page
Each topic gets its own section in a narrow page.
Loading demo: form-section-settings
When to use
- Long forms split into topics
- Settings pages with several groups
- Edit pages with personal, account and security parts
- Any form with more than six fields
When not to use
- Short forms about one topic
- Replacing the page title
- Wrapping a single field
- Dialogs and narrow panels — use a Field Group
Props
Prop | Type | Default | Required |
|---|---|---|---|
title | ReactNode | — | optional |
description | ReactNode | — | optional |
layout | "stacked" | "side-by-side" | "stacked" | optional |
headingLevel | 2 | 3 | 4 | 5 | 6 | 2 | optional |
dir | "ltr" | "rtl" | inherited | optional |
children | ReactNode | — | optional |
Accessibility
- Renders a <section> named by its heading (aria-labelledby), so it is a landmark in the page outline.
- Pick headingLevel so the titles follow the page heading order.
- The description is linked with aria-describedby and sits before the fields.
- Required fields are marked in their labels, as text.
Responsive behavior
- Use Side by side on wide screens: it stacks automatically whenever the section is narrower than 40rem (a container query, so it also works inside narrow columns).
- Spacing and type use the responsive tokens.
- The fields column shrinks with the page; nothing has a fixed width except the 280px title column in the side-by-side layout.