Appearance
Input โ
A single-line text input with sizes, color and visual variants, validation states, prefix/suffix slots and a clearable button. Toggle Vue / CSS to switch the live demo and source together.
The look is Basecoat's .field / .input-group / .label (see Theme): a 1px --input border, an xs shadow, a 3px --ring focus ring, --muted-foreground placeholder and affixes, and text-sm label / message text. Dark mode is built in.
Basic โ
Default text input with label, placeholder and helper text.
Vue SFC
Types โ
text, email, password, number, tel, url, date, time and search.
Vue SFC
Formatting โ
format-display changes what the field SHOWS; format-value changes what it REPORTS. They are separate props on purpose โ a money field shows 10.000.000 and reports 10000000, so nothing downstream has to know a format was involved.
Each takes a pattern or a function. A pattern containing {} is a text template; anything else is a number pattern in the familiar spreadsheet syntax:
| token | meaning |
|---|---|
# | an optional digit |
0 | a required digit โ pads on commit |
, | turn grouping on |
. | the decimal point |
"โฆ" | a literal, as in "Rp"#,##0 |
{} | (template) where the typed text goes |
A pattern is a shape, not the characters: #,##0.## prints 10,000.25 under en-US and 10.000,25 under id-ID. format-locale picks which โ leave it unset and you get the runtime default, which is rarely what a business app wants.
format-value normalises rather than decorates. A number pattern yields a plain numeric string ("10000000.25"), so Number(value) works; a template yields the assembled string, because there the decoration is the value.
A numeric format needs type="text"
A native type="number" input rejects any value that is not a bare number, so the moment a grouping separator appears the browser blanks the field. Use type="text" with inputmode="numeric" โ the demo below does.
Vue SFC
Bounds โ
On a field with a number format, min and max clamp the value rather than just annotating it:
html
<mono-input type="text" inputmode="decimal" max="100"
format-display="#,##0.##" format-value="#,##0.##" format-locale="id-ID" />max applies as you type โ type 1000 into the field above and it is cut to 100 on the keystroke, so the field can never be pushed past the ceiling. min applies on commit only: a lower bound is crossed on the way to almost every legal value, so clamping it live would make min="10" rewrite your first 1 into 10 and put 15 out of reach.
This is the one place those two props do anything here. Elsewhere they are forwarded to the native input, and the platform honours them only on number, range and the date types โ never on type="text", which is exactly what a numeric format requires. Values arriving from outside (a model-value binding, a form write-back) are not clamped; this bounds typing, not data.
format-on="blur" holds the raw text while you type and formats on commit. It is the escape hatch for fields where live rewriting fights the typist โ the decimal separator being the usual case, since it can be typed freely when nothing reformats underneath.
Templates and functions โ
A {} template puts the typed text in the hole and keeps the rest literal. The function form โ (ctx) => string, receiving { value, type, locale } โ covers anything the grammar cannot say, and needs a .prop binding since a function cannot cross an attribute.
Vue SFC
The event detail carries both: detail.modelValue is the value, detail.displayValue is the text on screen. A controlMonoForm reads modelValue, so a bound form stores the normalised value while the field shows the formatted one.
Sizes โ
xs โฆ xxl on the shared control ladder (--mono-control-height-*). Text follows the button's steps: xs is text-xs, sm/md/lg are text-sm, xl text-base, xxl text-lg. The default size is text-base under 48rem (Basecoat's text-base md:text-sm โ no iOS zoom on focus).
Vue SFC
Colors โ
Pick a colour and every variant takes it. color sets the focus colour โ the ring and the focused border. A resting field is always on --input, whatever its colour (Basecoat idiom); primary focuses with --ring, secondary with --muted-foreground, the rest with their role token.
outlined is Basecoat's .input-group. The other two borrow their look from two of Basecoat's own styles: filled is luma's field (a transparent border on an --input/50 surface, no shadow) and underlined is sera's (square, only the bottom edge painted, no ring โ focus and validation recolour the line). Under the sera flavor the default variant is the underline.
Vue SFC
States โ
Disabled, readonly and required.
Vue SFC
Validation โ
valid, invalid and warning states with messages. invalid is Basecoat's aria-invalid treatment โ a permanent --destructive border and /20 ring, the label turns --destructive too, and the message carries role="alert"; the other two are the same pattern in --success / --warning.
Vue SFC
Prefix & suffix โ
Icon or text on either side of the native input.
Vue SFC
Clearable โ
Clear button shown when the value is non-empty.
Vue SFC
Field alignment โ
--mono-control-height-* is the painted outer height of a control, so mono-input, mono-select, mono-date, mono-tag-input and mono-button are exactly the same height at the same size and line up in a form row without any per-field tweaking.
Vue SFC
Event log โ
Live log of input, change and clear events.
Vue SFC
Customized โ
Override per-element styling with the cssClass prop (Vue) or extra utility classes (CSS).
Vue SFC
Width & height โ
Set width, height, min-width, max-width, min-height or max-height โ each takes a CSS string ("260px", "80%") or a number (px). Fields are full width by default; set width to constrain.
Vue SFC
CSS Variables โ
Vue SFC
Every input is themed through --mono-input-* custom properties. Setting one on the element, on any wrapper/ancestor, or inline all work โ custom properties inherit, and they pierce the shadow-DOM boundary, so the same overrides apply to <mono-input> and the shadow build. The color prop sets the focus colour, but an explicit --mono-input-ring-color override always wins. To re-skin globally, set the underlying tokens (--input, --ring, --radius โฆ) โ or switch flavor.
| Variable | Default | Controls |
|---|---|---|
--mono-input-ring-color (alias --mono-input-focus-color) | --ring | Focus colour: the ring and the focused border (set by color) |
--mono-input-ring-width / --mono-input-ring-alpha | --mono-ring-width (3px) / --mono-ring-alpha (50%) | Ring geometry |
--mono-input-border-color (alias --mono-input-rest-border) | --input | Resting border |
--mono-input-side-border-color | = border | The top / left / right edges only (sera and underlined set transparent) |
--mono-input-bg (alias --mono-input-surface) | --mono-mode-surface (transparent, dark --input/30) | Field background |
--mono-input-shadow | --mono-shadow-xs (outlined) | Resting shadow |
--mono-input-radius / --mono-input-radius-<size> | --mono-radius-md | Corner radius, for every size / one step |
--mono-input-height-<size> | --mono-control-height-<size> | Field height per step |
--mono-input-padding-x-<size> | 2.5 ร --mono-spacing (xs 2, xl 3, xxl 4) | Text inset |
--mono-input-font-<size> / --mono-input-line-height (-<size>) | --mono-text-sm / its line height | Field text |
--mono-input-gap | 3 ร --mono-spacing | Label โ field โ message spacing |
--mono-input-label-font-size / -font-weight / -line-height / -text-transform / -letter-spacing / -gap | --mono-text-sm / --mono-label-font-weight / 1 / none / normal / 2 ร spacing | Label |
--mono-input-message-font-size / -line-height | --mono-text-sm / --mono-leading-normal | Message |
--mono-input-affix-padding / -gap / -font-size / -icon-size | 2 ร spacing / 1.5 ร spacing / field text / 4 ร spacing | Prefix / suffix inset, their gap to the text, text and glyph size |
--mono-input-clear-radius | calc(var(--radius) - 5px) | Clear button corner |
--mono-input-disabled-bg / --mono-input-readonly-bg | field bg / --muted | State surfaces |
--mono-input-filled-bg | --input/50 | filled surface |
--mono-input-outline-{bg,border-color,side-border-color,shadow,ring-width,radius,padding-x,affix-padding} | unset | The same knobs scoped to the outlined variant โ what the flavors set |
--mono-input-color, --mono-input-placeholder, --mono-input-muted | --foreground, --muted-foreground, --muted-foreground | Text, placeholder, affix / message ink |
--mono-input-valid / --mono-input-invalid / --mono-input-warning | --success / --destructive / --warning | Validation colours |
--mono-input-primary โฆ --mono-input-info | the role tokens | The color presets |
Deprecated and honoured as no-ops until 2.0: --mono-input-focus-rgb (alpha now comes from --mono-input-ring-alpha), --mono-input-underline-glow (the underline no longer glows โ it is sera's line), the per-colour filled tints (a flat --input/50 for every colour).
Types โ
Import
import { InputProps } from 'mono-helper'| Prop | Value | Default | Description |
|---|---|---|---|
type | 'number' | 'text' | 'date' | 'time' | 'email' | 'password' | 'tel' | 'url' | 'month' | 'week' | 'search' | โ | Native input type controlling the field's behavior and keyboard. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | โ | Visual size of the input field. |
color | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'teal' | 'purple' | 'neutral' | 'dark' | โ | Theme color applied to focus, borders, and accents. |
variant | 'underlined' | 'outlined' | 'filled' | โ | Visual style of the field (outlined, filled, or underlined). |
placeholder | string | โ | Placeholder text shown when the field is empty. |
value | string | number | โ | Current input value. |
name | string | โ | Form field name submitted with the input. |
modelValue | string | โ | Two-way bound value for v-model-style usage. |
formatDisplay | string | (ctx: InputFormatCtx) => string | โ | How the field is DISPLAYED โ a pattern (`#,##0.##`, `{}@gmail.com`) or a function. Never changes the value. A numeric pattern requires `type="text"`. |
formatValue | string | (ctx: InputFormatCtx) => string | โ | How the VALUE is shaped. A numeric pattern normalises to a plain numeric string (`"10000000.25"`); a template assembles the full string. |
formatOn | 'input' | 'blur' | โ | When the display reformats: `'input'` (default) or `'blur'`. |
formatLocale | string | โ | Locale a numeric pattern is drawn with โ the pattern is a shape, the locale the characters. |
disabled | boolean | โ | Disables interaction and dims the field. |
readonly | boolean | โ | Makes the field read-only while still focusable. |
clearable | boolean | โ | Shows a clear button when the field has a value. |
required | boolean | โ | Marks the field as required and shows a required indicator. |
autofocus | boolean | โ | Focuses the field automatically on first render. |
label | string | โ | Label text displayed above the field. |
helperText | string | โ | Helper text shown below the field. |
validationState | 'warning' | 'default' | 'valid' | 'invalid' | โ | Explicit validation state for styling and messaging. |
validationMessage | string | โ | Validation message shown below the field. |
error | boolean | โ | Marks the field in an error state. |
errorMessage | string | โ | Error message shown below the field. |
success | boolean | โ | Marks the field in a success state. |
successMessage | string | โ | Success message shown below the field. |
ariaLabelText | string | โ | Accessible label for the input element. |
ariaLabel | string | โ | Shorter alias for the accessible label. |
minLength | number | โ | Minimum allowed input length. |
maxLength | number | โ | Maximum allowed input length. |
min | string | number | โ | Minimum value. On a field with a NUMBER `format` this clamps the typed value on commit (never while typing โ a lower bound is crossed on the way to most legal values). On every other type it is the native attribute. |
max | string | number | โ | Maximum value. On a field with a NUMBER `format` this clamps the typed value AS YOU TYPE, so the field cannot be pushed past it. On every other type it is the native attribute โ note the platform ignores it on `type="text"`, which a numeric format requires. |
step | string | number | โ | Step increment for numeric or date inputs. |
pattern | string | โ | Validation pattern the value must match. |
autocomplete | string | โ | Native autocomplete hint for the field. |
inputmode | string | โ | Native inputmode hint for the on-screen keyboard. |
width | string | number | โ | Explicit sizing. Each accepts a CSS length string (`"320px"`, `"80%"`) or a number (interpreted as px). Use `width="100%"` for a full-width field. |
height | string | number | โ | โ |
minWidth | string | number | โ | โ |
maxWidth | string | number | โ | โ |
minHeight | string | number | โ | โ |
maxHeight | string | number | โ | โ |
cssClass | InputCssClass | โ | Per-part class overrides for internal elements. |
visible | boolean | โ | Whether the control is shown. Defaults to `true`. |
visibleType | 'none' | 'invisible' | โ | How it hides when `visible` is `false`. Defaults to `'none'`. |