Label
The visible name of a form control.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- Built on radix-ui/Label
- A real <label>: clicking it focuses the control it names.
- required adds a visual marker; set required on the control for assistive tech.
- Styles in one file:
03-form-fields.css
Import
import '@monoline/css';
import {Label} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add label
It needs radix-ui; install it if your project does not have it:
npm install radix-ui
Usage
import {Label} from '@monoline/react';
<div style={{display: 'grid', gap: 'var(--s2)', maxWidth: 320}}>
<Label htmlFor="demo-label" required>Email</Label>
<input id="demo-label" className="input" placeholder="[email protected]" />
</div>
Examples
Label for a control
Props
LabelProps
| Prop | Type | Default | Description |
|---|---|---|---|
required | boolean | – | Adds a required marker. Pair with `required` on the control. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[aria-checked="true"] | 03-form-fields.css |
[aria-invalid="true"] | 03-form-fields.css |
[aria-pressed="true"] | 03-form-fields.css |
CSS classes
| Class | Stylesheet |
|---|---|
.field | 03-form-fields.css |
.field-hint | 03-form-fields.css |
.input | 03-form-fields.css |
.input-bare | 03-form-fields.css |
.input-end | 03-form-fields.css |
.input-lg | 03-form-fields.css |
.input-sm | 03-form-fields.css |
.input-wrap | 03-form-fields.css |
.muted | 03-form-fields.css |
.seg | 03-form-fields.css |
.seg-opt | 03-form-fields.css |
.select | 03-form-fields.css |
.setting | 03-form-fields.css |
.switch | 03-form-fields.css |
.textarea | 03-form-fields.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
.field {
border-color: var(--accent);
}
.field[aria-checked="true"] {
background: var(--wash);
}
Accessibility
- A real <label>: clicking it focuses the control it names.
- required adds a visual marker; set required on the control for assistive tech.