Input
A single-line text field.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- Built on native elements
- Native <input>: all keyboard and autofill behaviour is the browser's.
- Inside a Field it is labelled and described automatically; invalid sets aria-invalid.
- Styles in one file:
03-form-fields.css
Import
import '@monoline/css';
import {Input} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add input
Usage
import {Input} from '@monoline/react';
<div style={{maxWidth: 320}}>
<Input aria-label="Name" placeholder="Ada Lovelace" />
</div>
Examples
Basic
States
Props
InputProps
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | 'md' | `md` (default), `sm` for dense layouts or `lg` for prominent forms. Heights match Button and the other form controls at each size. |
invalid | boolean | – | Marks the control invalid (`aria-invalid`). A surrounding Field sets this from its `error`. |
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 |
[data-valid="true"] | 11-field-states.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 |
.field-error | 11-field-states.css |
.field-ok | 11-field-states.css |
.field-required | 11-field-states.css |
.form-row | 11-field-states.css |
.input | 11-field-states.css |
.input-affix | 11-field-states.css |
.input-group | 11-field-states.css |
.select | 11-field-states.css |
.textarea | 11-field-states.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);
}
Try the props
Change a prop and the component above updates; the code below is what you would write. To edit the code itself, use the Playground.
example.tsx
<Input aria-label="Email" placeholder="you@example.com" />
Accessibility
- Native <input>: all keyboard and autofill behaviour is the browser's.
- Inside a Field it is labelled and described automatically; invalid sets aria-invalid.