Raft Design System

Components · Layout

FormSection

One part of a large form, with a small heading, a quiet status chip, a line on what the part is for, and its fields, used in the wide dialog and in drawer forms.

Stable
import { FormSection } from "@botiverse/raft-ui";

A form section is one part of a large form: a small heading, an optional status chip, one line on what the part is for, then its fields. A large form is a stack of them, in the wide Dialog or in a Drawer; the two use the same section.

When to use

SituationUse
A part of the large form dialog, listed in its DialogNavFormSection
A part of a form in a drawerFormSection
A form of 2 or 3 fieldsNo sections: put the fields in the body of the Dialog

How the large form dialog is built around its sections is in Forms.

Anatomy

FormSection is one part. It renders, in order:

  • The heading: text-footnote, bold, in foreground-muted. Required.
  • The status, at the end of the heading row: a soft, muted Badge. Optional.
  • The description, under the heading: text-footnote in foreground-hint. The description prop takes only a HelperText, made with helperText(content, { why, about }), and renders its why and about as data-why and data-about. Optional.
  • Its children: the fields (Field), and any action rows.

Behavior

  • Fields in a section are 12px apart.
  • Sections are section-gap apart (32px on a phone, 24px on a desktop, half on each side), with a line-hairline between two sections. The first section starts flush with the top of its container, and the last ends flush with its bottom: a section keeps no room outside itself.
  • The container gives the room around the sections. In the large form dialog that is the sections pane, padded by --surface-inset on every side, the top included, so the first heading and its status chip sit clear of the header's seam (Forms); in a drawer it is the drawer's body.

Content

  • Write the status as one quiet word on where the section stands: Complete, Optional, Off, Private.
  • Give a section a description only when it has a consequence its heading doesn't say: what is lost, who sees it, or how to recover ("Shown to everyone who opens the Marketplace", audience). A line on what the section is for ("Public identity and Marketplace-facing metadata") is cut: the heading says that (Writing › Helper text).

Accessibility

  • FormSection renders a section with an h3 heading. Put it under a dialog or drawer title, which is the level above.
  • Give each section an id when a DialogNav links to it, so the section list can jump there.

Rules

  • Write actions inside a section as ordinary rows, and show only the sections that can be filled in before an item is saved, as in Forms.

API

FormSection

One part of a bigger form (a wide dialog or sheet): a small heading with its status and, when it has a consequence, a helper line, then its fields. Consecutive sections are separated by a hairline.
PropTypeDefault
descriptionA line under the heading, only when the section has a consequence its title doesn't say: what is lost, who sees it, how to recover. Not what the section is for: its title says that.HelperText
statusWhere this part stands (Complete, Optional, Off …): a quiet tag.ReactNode
title (required)ReactNode
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

Changes

  • 0.106.0 · Design SystemA large form dialog's sections pane supplies their inset ([Forms › The large form dialog](https://raft-design.botiverse.build/patterns/forms/#the-large-form-dialog), [FormSection](https://raft-design.botiverse.build/components/form-section/#behavior)): the pane the sections scroll in pads its content by --surface-inset on every side, the top included, since a FormSection starts flush with its container.
  • 0.103.0 · Breaking ChangesExplanation slots take only a HelperText: FieldDescription, FormSection's description, a ChoiceList item's description, SelectItemDescription, DialogDescription, AlertDialogDescription, DrawerDescription, PopoverDescription, EmptyStateDescription, CardDescription, CardFooter, BannerDescription, DialogFooterNote (work in progress), MessageActionCardHint, MessageActionCardHeaderDescription, MessageActionCardScopeDescription and MessageActionCardActionsNote. A HelperText is made only by helperText(content, { why, about }): content is any ReactNode (a string, a formatted message, a TextLink inside a sentence), why is "consequence", "audience" or "recovery", and about names the thing the line is about. Each slot renders the content with data-why and data-about, and in development warns once when it is given anything else, which it still renders. ToastDescription, NotificationCenterItemBody, EmptyStateTitle, ListRowDescription and the status and data parts are unchanged.
  • 0.6.0 · ChangedFormSection's first section starts flush with its container.