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. Children can span columns with inline styles.

Address
View code
<Fieldset label="Address" grid columns={2} bordered>
<Input label="Street Address" name="street" style="grid-column: 1 / -1" />
<Input label="City" name="city" />
<Input label="State" name="state" />
<Input label="ZIP Code" name="zip" />
<Input label="Country" name="country" />
</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"