Fieldset
Group related controls under one legend.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
legend required | ReactNode | – | 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
| Class | Stylesheet |
|---|---|
.fieldset | fieldset.css |
.fieldset-legend | fieldset.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.