Fieldset
Import
Section titled “Import”import { Fieldset } from '@delightstack/components';Basic Usage
Section titled “Basic Usage”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>Examples
Section titled “Examples”Bordered
Section titled “Bordered”Bordered
View code
<Fieldset bordered label="Account settings"> <Input label="Username" name="username" required /> <Input label="Password" type="password" name="password" required /></Fieldset>Grid Layout
Section titled “Grid Layout”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.
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>Collapsible
Section titled “Collapsible”Click the label, the expand stub, or press Enter/Space to expand or collapse the content. Bind collapsed for controlled state.
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>With Description and Error
Section titled “With Description and Error”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>Skeleton Loading
Section titled “Skeleton Loading”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>| Prop | Type | Default | Description |
|---|---|---|---|
label | string | - | Section title rendered as <legend> |
description | string | - | Helper text below the label |
bordered | boolean | false | Subtle border style |
disabled | boolean | false | Disable all child fields natively |
error | string | - | Group-level error message |
required | boolean | false | Show required asterisk on label |
collapsible | boolean | false | Allow collapsing the content |
collapsed | boolean | false | Collapsed state, bindable |
grid | boolean | false | Enable CSS Grid layout for children |
columns | number | 2 | Number of grid columns (when grid is true) |
skeleton | boolean | false | Show skeleton loading state |
dense | boolean | false | Compact spacing between fields |
comfortable | boolean | false | Relaxed spacing between fields |
id | string | auto | Element ID |
class | string | '' | Additional CSS classes |
children | Snippet | - | Form field content |
Accessibility
Section titled “Accessibility”- Semantic
<fieldset>and<legend>HTML elements aria-describedbylinks 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"