Skip to content
Focsd homeFocsd homeFocsd
Forms

Fieldset

Groups related fields under a legend, with a shared hint and error.

  • Tag: focsd-fieldset
  • Pattern: Fieldset + legend
  • Category: Forms

Example

HTML
<focsd-fieldset label="Shipping address" hint="We only ship within the EU.">
<focsd-text-field label="Street"></focsd-text-field>
<focsd-text-field label="City"></focsd-text-field>
</focsd-fieldset>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-fieldset.js';
</script>
<focsd-fieldset label="Shipping address" hint="We only ship within the EU.">…</focsd-fieldset>

API

Attributes

AttributePropertyTypeDefault
labellabelstring—
hinthintstring—
errorerrorstring | undefined—
disableddisabledbooleanfalse
namenamestring—

Slots

SlotDescription
(default)Default content.

CSS parts

Style the inside of the component with ::part(), for example focsd-fieldset::part(error).

PartDescription
errorThe error element.
fieldsetThe fieldset element.
hintThe hint element.
itemsThe container around the slotted controls.
legendThe legend element.

Accessibility

  • disabled disables every control inside (native or Focsd), leaving them out of validation and the form data, like a native fieldset. Controls you disabled yourself stay disabled when the fieldset is enabled again.
  • A shadow <fieldset> with <legend>; screen readers announce the legend when focus enters the group.