Skip to content

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:

tokenmeaning
#an optional digit
0a 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

Tooltip โ€‹

When the extra explanation is too long for helper-text, put it behind an info icon at the end of the label. tooltip="โ€ฆ" takes plain text; :tooltip.prop="{ content, placement, color, โ€ฆ }" takes any tooltip option. The icon is keyboard-focusable and also works on a disabled field โ€” a good place to say why it is disabled.

Plain text needs nothing extra

tooltip="โ€ฆ" (plain text) shows a small built-in bubble โ€” no dependency. It sits above the icon (below when there's no room), stays on screen, and isn't clipped by an overflow: hidden parent. It reads the tooltip addon's --mono-tooltip-bg / -color / -radius / -max-width / -font-size / -padding-x / -padding-y knobs.

The object form is the tooltip addon (mono-tooltip: placement, color, delayโ€ฆ), which needs the optional peers pnpm add @floating-ui/dom @floating-ui/core. Without them an object-form tooltip renders no icon (and nothing is logged). Either way the icon only appears beside a label.

Vue SFC

Label position โ€‹

label-position moves the label without touching its type or colours:

valuelook
topabove the box (default)
notchedoutlined: on the top border, โ”€โ”€Labelโ”€โ”€. filled / underlined: inset inside the top of the box, which grows by the label's line
left / rightbeside the box, centred on its first row; helper / validation messages stay under the box

Set it for every field at once with createMonoUI({ 'mono-input': { labelPosition: 'notched' } }). --mono-input-label-width fixes the side column so a stack of left fields lines up.

The notch is a background patch

The notch hides the border with --background. On a card or any other surface, set --mono-input-label-notch-bg to that surface (e.g. var(--card)).

Vue SFC

Validation position โ€‹

validation-position decides where the validation message (invalid / warning / valid + validation-message) shows. The coloured border is the same in every mode.

valuelook
bottomthe row under the box (default) โ€” the message replaces the helper text there
icona state icon inside the box; hover or tap it (or keyboard-focus the field) for the message in a state-coloured bubble
floatnothing until the field is hovered or focused; then the message floats under the box, and disappears again when you leave

In icon and float the row under the box keeps the helper text, and the message stays there for screen readers only. The bubbles need no dependency (no floating-ui). Knobs: --mono-validation-invalid-bg / -color (and warning / valid), --mono-validation-icon-size.

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

File โ€‹

type="file" gives a classic one-line file picker. It behaves like mono-file-upload but has no dropzone and no file list. The field shows the picked name(s) read-only and has an upload icon (i-mdi-cloud-upload-outline) at the end. A click on the field or the icon, or Enter / Space while it is focused, opens the native dialog.

  • Value: modelValue is the picked File (null when empty). With multiple it is File[] and the names are comma-joined. A file object cannot cross an attribute, so bind it with :model-value.prop. A bound controlMonoForm receives the File as is, ready for FormData.
  • accept: passed to the native picker, e.g. accept=".pdf,image/*".
  • max-file-size: a size limit in bytes. Each oversized file is dropped and reported through error ({ message, reason: 'max-file-size', file, maxFileSize }, the same shape mono-file-upload uses). When every picked file is rejected, the previous value stays.
  • clearable: the ร— resets the value to null (or [] with multiple) and emits input, change and clear.
  • Events: input and change both fire on a pick. detail.files always holds the files as an array.
Vue SFC

Range โ€‹

type="range" is Basecoat's slider (.field > input[type='range']). It has no bordered box: the track fills with the color prop's accent, and the thumb sits on it. Each Basecoat style draws its own track and thumb, from vega's white dot on a 6px track to luma's pill or sera's square.

Under ONE (the default) it follows the EJI guide's .eji-range instead. The track is a 4px line with no fill. The thumb is a 16px navy dot with a white rim. The label row is 12px and ends in the value, shown in bold navy mono figures.

  • Value: modelValue is the number as a string ("5"), with the native min (default 0), max (default 100) and step (default 1). input fires while dragging, change on release. An empty value is shown at the midpoint, as the native slider does, and the model is not rewritten.
  • Readout: on by default, because the guide never shows a slider without its number. With a label, the value sits at the end of the label row. Without one, it follows the slider. show-value="false" hides it.
  • format-display shapes only the readout (and aria-valuetext). The native value stays a bare number. Use format-display="{}%", a number pattern such as '"Rp "#,##0' with format-locale="id-ID", or a function: :format-display.prop="({ value }) => โ€ฆ".
  • disabled fades the slider. readonly keeps it focusable but puts the thumb back on any move. clearable has no effect.
  • Restyle through --mono-input-range-*: track-height, track-bg, fill, thumb-size, thumb-bg, thumb-border-*, thumb-ring-*, ring-width, value-color, and more (see the CSS variables table). size scales the thumb and track.
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.

VariableDefaultControls
--mono-input-ring-color (alias --mono-input-focus-color)--ringFocus 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)--inputResting border
--mono-input-side-border-color= borderThe 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-mdCorner 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 heightField text
--mono-input-gap3 ร— --mono-spacingLabel โ†” 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 ร— spacingLabel
--mono-input-label-width / -label-side-gapauto / 3 ร— spacinglabel-position left / right column
--mono-input-label-notch-font-size / -label-notch-bg--mono-text-xs / --backgroundlabel-position="notched"
--mono-input-message-font-size / -line-height--mono-text-sm / --mono-leading-normalMessage
--mono-input-affix-padding / -gap / -font-size / -icon-size2 ร— spacing / 1.5 ร— spacing / field text / 4 ร— spacingPrefix / suffix inset, their gap to the text, text and glyph size
--mono-input-clear-radiuscalc(var(--radius) - 5px)Clear button corner
--mono-input-disabled-bg / --mono-input-readonly-bgfield bg / --mutedState surfaces
--mono-input-filled-bg--input/50filled surface
--mono-input-outline-{bg,border-color,side-border-color,shadow,ring-width,radius,padding-x,affix-padding}unsetThe same knobs scoped to the outlined variant โ€” what the flavors set
--mono-input-color, --mono-input-placeholder, --mono-input-muted--foreground, --muted-foreground, --muted-foregroundText, placeholder, affix / message ink
--mono-input-valid / --mono-input-invalid / --mono-input-warning--success / --destructive / --warningValidation colours
--mono-input-primary โ€ฆ --mono-input-infothe role tokensThe color presets
--mono-input-accent--primary (set by color / a validation state)type="range": the fill and thumb colour
--mono-input-range-track-height / -track-radius / -track-bg / -fill0.375rem / full / --muted / the accenttype="range": the track, and its filled part
--mono-input-range-thumb-size / -thumb-width / -thumb-radius / -thumb-bg1rem / = size / full / whitetype="range": the thumb (border-box)
--mono-input-range-thumb-border-width / -border-color / -ring-width / -ring-color / -shadow1px / the accent / 0 / โ€“ / --mono-shadow-smtype="range": the thumb's rim, resting ring and shadow
--mono-input-range-ring-width / -hover-ring-width4px / = ring widthtype="range": the focus / hover halo (colour = the ring at --mono-ring-alpha)
--mono-input-range-height / -gap1.25rem / --mono-input-gaptype="range": the slider's box, and label โ†” slider spacing
--mono-input-range-label-color / -font-size / -line-height / -font-weightthe label'stype="range": the label row
--mono-input-range-value-color / -font-family / -font-size / -font-weight / -min-width--muted-foreground / inherit / the label's / medium / 3chtype="range": the value readout

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 โ€‹

Importimport { InputProps } from '@mono-lit/helper'
PropValueDefaultDescription
type'number' | 'text' | 'date' | 'time' | 'range' | 'email' | 'password' | 'tel' | 'url' | 'month' | 'week' | 'search' | 'file'โ€”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).
labelPosition'left' | 'right' | 'top' | 'notched'โ€”Where the label sits: `top` (above the box, default), `notched` (on the top border for outlined; inset inside the box for filled / underlined), or `left` / `right` of the box. Knobs: `--mono-input-label-width`, `-label-side-gap`, `-label-notch-font-size`, `-label-notch-bg`.
validationPosition'bottom' | 'icon' | 'float'โ€”Where the validation message shows. `bottom` (default): the row under the box. `icon`: a state icon inside the box; hover / tap / keyboard focus shows the message in a state-coloured bubble. `float`: the message floats under the box only while the field is hovered or focused. In `icon` / `float` the row under the box keeps the helper text.
placeholderstringโ€”Placeholder text shown when the field is empty.
valuestring | numberโ€”Current input value.
namestringโ€”Form field name submitted with the input.
modelValuenull | string | File | File[]โ€”Two-way bound value for v-model-style usage. For `type="file"` it is the picked `File` (`null` when empty), or `File[]` with `multiple`.
acceptstringโ€”`type="file"` โ€” the native `accept` filter (`"image/*,.pdf"`).
multiplebooleanโ€”`type="file"` โ€” allow picking several files; `modelValue` becomes `File[]`.
maxFileSizenumberโ€”`type="file"` โ€” reject files larger than this many bytes (emits `error`).
showValuebooleanโ€”`type="range"` โ€” show the current value beside the slider (default `true`): at the end of the label row, or after the slider when there is no label. It is drawn through `format-display`, so `format-display="Rp {}"` or a function shapes it. `show-value="false"` hides it.
formatDisplaystring | (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"`.
formatValuestring | (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'`.
formatLocalestringโ€”Locale a numeric pattern is drawn with โ€” the pattern is a shape, the locale the characters.
disabledbooleanโ€”Disables interaction and dims the field.
readonlybooleanโ€”Makes the field read-only while still focusable.
clearablebooleanโ€”Shows a clear button when the field has a value.
requiredbooleanโ€”Marks the field as required and shows a required indicator.
autofocusbooleanโ€”Focuses the field automatically on first render.
labelstringโ€”Label text displayed above the field.
helperTextstringโ€”Helper text shown below the field.
tooltipstring | MonoTooltipOptionsโ€”Info icon at the end of the label; hovering, focusing or tapping it shows this text. Plain text โ†’ a small built-in bubble (no dependency). Full tooltip options (`:tooltip.prop="{ content, placement, color }"`) โ†’ a `mono-tooltip`, which needs the optional `@floating-ui/dom` + `@floating-ui/core` peers (without them that form renders no icon). Shown only beside a label.
validationState'warning' | 'default' | 'invalid' | 'valid'โ€”Explicit validation state for styling and messaging.
validationMessagestringโ€”Validation message shown below the field.
errorbooleanโ€”Marks the field in an error state.
errorMessagestringโ€”Error message shown below the field.
successbooleanโ€”Marks the field in a success state.
successMessagestringโ€”Success message shown below the field.
ariaLabelTextstringโ€”Accessible label for the input element.
ariaLabelstringโ€”Shorter alias for the accessible label.
minLengthnumberโ€”Minimum allowed input length.
maxLengthnumberโ€”Maximum allowed input length.
minstring | 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.
maxstring | 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.
stepstring | numberโ€”Step increment for numeric or date inputs.
patternstringโ€”Validation pattern the value must match.
autocompletestringโ€”Native autocomplete hint for the field.
inputmodestringโ€”Native inputmode hint for the on-screen keyboard.
widthstring | 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.
heightstring | numberโ€”โ€”
minWidthstring | numberโ€”โ€”
maxWidthstring | numberโ€”โ€”
minHeightstring | numberโ€”โ€”
maxHeightstring | numberโ€”โ€”
cssClassInputCssClassโ€”Per-part class overrides for internal elements.
visiblebooleanโ€”Whether the control is shown. Defaults to `true`.
visibleType'none' | 'invisible'โ€”How it hides when `visible` is `false`. Defaults to `'none'`.