Forms

FormSection

Sectioning wrapper that groups related form fields under a heading or legend and applies a responsive column layout.

import { FormSection } from '@lostgradient/cinder';
formlayout
01

Overview

Reference usage

Groups related form fields under a heading with optional description and layout control.

Usage

svelte
<script lang="ts">
  import { FormField } from '@lostgradient/cinder';
  import { FormSection } from '@lostgradient/cinder';
  import { Input } from '@lostgradient/cinder';
  let street = $state('');
  let city = $state('');
  let postalCode = $state('');
</script>

<FormSection
  as="fieldset"
  heading="Shipping address"
  description="Where should we send your order?"
  columns={2}
>
  <FormField id="street" label="Street address">
    <Input id="street" bind:value={street} placeholder="123 Main St" />
  </FormField>
  <FormField id="city" label="City">
    <Input id="city" bind:value={city} placeholder="Springfield" />
  </FormField>
  <FormField id="postal-code" label="Postal code">
    <Input id="postal-code" bind:value={postalCode} placeholder="12345" />
  </FormField>
</FormSection>

Heading note

meta puts a short muted note beside the heading on its baseline ("Read with every chat", "3 of 9"). It is outside the heading element, so the heading's accessible name stays the heading text; in a fieldset the note sits inside the legend after the text. Use description for a sentence of guidance. When that sentence holds markup, such as a file name in code, pass descriptionContent instead: the snippet is drawn inside the same description paragraph, in the same style, in place of description.

Grouped sections

grouped draws the children as one card with a divider between them, on the GroupedList's surface (the raised fill, no border, the surface radius, a 16px inset), under its heading and description. The heading steps with headingLevel as a Section title does: large at level 2, the base size at level 3, smaller and muted below that. It is the frame of a settings page: each child is a SettingRow, and a grouped section is always one column whatever columns says.

svelte
<script lang="ts">
  import { FormSection, Input, SettingRow } from '@lostgradient/cinder';
</script>

<FormSection grouped heading="Runs" description="Settings that apply after a restart say so.">
  <SettingRow id="runs-limit" label="Max concurrent runs" identifier="engine.maxConcurrentRuns">
    {#snippet control()}<Input id="runs-limit" value="4" />{/snippet}
  </SettingRow>
</FormSection>

A section with no children draws its heading and description alone, for a list that has nothing in it yet and says so in the page's own words beneath, with no empty card.

Live preview

Account settings panel

Account

Update your display name and email address.

Privacy

Control who can see your profile and what communications you receive.

Public profile Marketing emails

02

When to use

Use when
  • Splitting a long form into labelled segments such as "Account" or "Billing".
  • Rendering a fieldset with a legend for a set of tightly related inputs.
Avoid when
  • Wrapping a single control with its label and error — use form-field instead.
03

Examples

Account settings panel

FormSection groups related account and privacy controls under a headed section. Text fields use FormField + Input; on/off settings use Toggle standalone (it renders its own label).

Fieldset with legend

Use as="fieldset" for semantically grouped inputs. The heading prop becomes a <legend>.

Responsive grid

Container-query-driven layout. Resize the outer container to see the grid respond.

04

Props

Props for form-section
Name
Type
Default
Description
as discriminated-union 'section' Wrapper element. Default.
heading text Heading text rendered as <h{level}>.
headingLevel 23456 2 Heading level. Default 2.
description text Optional descriptive paragraph rendered under the heading/legend.
descriptionContent snippet The description with markup in it, such as a file name in code. It takes the place of description inside the same paragraph and in the same style, so a page that needs one code span does not draw its own paragraph beside the others.
meta text A short muted note beside the heading, on its baseline ("Read with every chat", "3 of 9"). It says what the section is for or how much is in it; a sentence of guidance is the description.
metaAlign 'inline' | 'end' 'inline' Places a short count or format note at the title row's end edge. The default keeps a note directly after its heading.
columns 1 | 2 | 3 | 4 2 Column ceiling. Container queries pick the actual rendered count. Default 2.
gap 'default' | 'loose' 'default' Space between ungrouped fields. loose uses Cinder's space-6 step.
grouped boolean false Draws the children as one card on the GroupedList's surface, each child separated from the next by a divider, under a heading sized by its level as a Section title is, and its description. For a page of settings: the children are SettingRows, and a grouped section is always one column.
borderTone 'default' | 'muted' 'default' The grouped card's structural edge. muted is an opt-in for a dense settings page where the card's surface and row dividers already establish the group.
children snippet Children (FormField instances or arbitrary content). Optional: a section with none draws its heading and description alone, for a list that is empty and says so in the page's own words.