Skip to content

Fieldset

import { Fieldset } from '@delightstack/components';
Personal information
View code
<Fieldset label="Personal information">
<Input label="First name" name="firstName" />
<Input label="Last name" name="lastName" />
<Input label="Email" type="email" name="email" />
</Fieldset>
Bordered
Account settings
View code
<Fieldset bordered label="Account settings">
<Input label="Username" name="username" required />
<Input label="Password" type="password" name="password" required />
</Fieldset>

Use grid to arrange children in a CSS grid. Wrap a field to span columns, so each one is as wide as what it holds — a long street line, a short state.

Address
View code
<Fieldset label="Address" grid columns={6} bordered>
<div style:grid-column="1 / -1"><Input label="Street address" name="street" /></div>
<div style:grid-column="span 3"><Input label="City" name="city" /></div>
<div style:grid-column="span 1"><Input label="State" name="state" /></div>
<div style:grid-column="span 2"><Input label="ZIP code" name="zip" /></div>
<div style:grid-column="span 3"><Input label="Country" name="country" /></div>
</Fieldset>

Click the label, the expand stub, or press Enter/Space to expand or collapse the content. Bind collapsed for controlled state.

Advanced options
View code
<script>
import { Fieldset, Input, Toggle } from '@delightstack/components';
let collapsed = $state(false);
</script>
<Fieldset label="Advanced options" collapsible bind:collapsed bordered>
<Input label="Custom domain" name="domain" />
<Toggle label="Enable API Access" name="api" />
</Fieldset>
Profile

This information is publicly visible

Permissions
Read
Write
View code
<Fieldset label="Profile" description="This information is publicly visible" bordered>
<Input label="Display name" name="displayName" />
<Input label="Bio" name="bio" />
</Fieldset>
<Fieldset label="Permissions" required error="Select at least one permission" bordered>
<Checkbox checked={false} label="Read" />
<Checkbox checked={false} label="Write" />
</Fieldset>
User profile
View code
<Fieldset skeleton={loading} label="User profile" bordered>
<Input label="Name" name="name" skeleton={loading} bind:value={name} />
<Input label="Email" name="email" skeleton={loading} bind:value={email} />
</Fieldset>
PropTypeDefaultDescription
labelstring-Section title rendered as <legend>
descriptionstring-Helper text below the label
borderedbooleanfalseSubtle border style
disabledbooleanfalseDisable all child fields natively
errorstring-Group-level error message
requiredbooleanfalseShow required asterisk on label
collapsiblebooleanfalseAllow collapsing the content
collapsedbooleanfalseCollapsed state, bindable
gridbooleanfalseEnable CSS Grid layout for children
columnsnumber2Number of grid columns (when grid is true)
skeletonbooleanfalseShow skeleton loading state
densebooleanfalseCompact spacing between fields
comfortablebooleanfalseRelaxed spacing between fields
idstringautoElement ID
classstring''Additional CSS classes
childrenSnippet-Form field content
  • Semantic <fieldset> and <legend> HTML elements
  • aria-describedby links to description and error text
  • Collapsible label is keyboard-activated with Enter/Space and uses aria-expanded
  • Native <fieldset disabled> propagates disabled state to all child form controls
  • Error message uses role="alert" for screen reader announcements
  • Required indicator shows red asterisk with aria-hidden="true"