Playground

Fieldset

Group related controls under one legend.

  • Built on native elements
  • Native fieldset and legend: screen readers announce the legend with each control.
  • disabled on the fieldset disables every control inside.
  • Styles in one file: fieldset.css

Import

import '@monoline/css';
import {Fieldset} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add fieldset

Usage

import {Field, Fieldset, Input} from '@monoline/react';

<div style={{maxWidth: '360px'}}>
  <Fieldset legend="Contact">
    <Field label="Name">
      <Input />
    </Field>
    <Field label="Email">
      <Input type="email" />
    </Field>
  </Fieldset>
</div>

Examples

Group

Props

FieldsetProps

PropTypeDefaultDescription
legend requiredReactNode–The group's name. Required so the fieldset always has an accessible name.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.fieldsetfieldset.css
.fieldset-legendfieldset.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.fieldset {
  border-color: var(--accent);
}

Accessibility

  • Native fieldset and legend: screen readers announce the legend with each control.
  • disabled on the fieldset disables every control inside.