Skip to main content

Fieldset

Groups related controls under a legend.

<mm-fieldset label="Connection" description="Marmot connects with a read-only service account.">
<mm-text-field name="host" label="Host" mono></mm-text-field>
<mm-number-field name="port" label="Port" value="443"></mm-number-field>
</mm-fieldset>

Guidance​

Fieldsets group related controls under one legend: "Schedule", "Notifications", "Connection". The legend uses the label style, an optional description sits under it, and controls stack space-4 apart (space-2 for a list of checkboxes or switches). There is no box by default, because structure should be felt and not seen; bordered adds a single hairline when a group must stand apart inside a long form.

disabled disables every control inside, native and Marmot alike, and restores exactly the controls it disabled when cleared. The legend and description name and describe the group for assistive technology through a native fieldset in the shadow root.

Properties​

PropertyAttributeTypeDefaultDescription
labellabelstring''The legend.
descriptiondescriptionstring''A sentence under the legend explaining the group.
errorerrorstring''Error text for the group as a whole, such as "Choose at least one channel."
disableddisabledbooleanfalseDisables every control inside.
borderedborderedbooleanfalseAdds a hairline border. Off by default.
requiredrequiredbooleanfalseShows "Required" or "Optional" beside the legend.
optionaloptionalbooleanfalse

Slots​

SlotDescription
DefaultThe controls.
labelA rich legend, in place of the label attribute.

CSS parts​

PartDescription
fieldsetThe native fieldset.
legendThe legend.
descriptionThe description line.
controlsThe wrapper that spaces the controls.
errorThe error line.

Examples​

Every state of mm-fieldset in Storybook, with keyboard and screen reader tests.