Input
A complete text field: label above, hint below, icons inside, a character counter, a clear button and a loading state, all around a real <input>.
Usage
Examples
Label and hint
label renders above the field and focuses it when clicked. hint renders under the field and is tied to it through aria-describedby.
Shown next to everything you publish.
Sizes
size sets the height to 32, 40 or 48 pixels, and compact takes 4px off any of them.
Icons
iconStart and iconEnd place a decorative icon at either end of the field. The #end slot replaces the end icon, where #start is rendered after the start icon rather than in its place.
This handle is free.
Clearable
clearable adds a cross that empties the field, shown while there is something to clear and the field can be edited. clearVisible answers that question yourself, for a field whose value is not its text.
States
disabled greys the field out and takes it out of the tab order. readonly keeps it focusable and copyable, and hides the clear cross unless told otherwise. invalid is for a rule the browser cannot check by itself, and loading puts a spinner where the end icon goes.
That handle is already taken.
Clickable icons
A @click:icon-start or @click:icon-end listener turns that icon into a real button, which then needs iconStartLabel or iconEndLabel.
Press the magnifier to search.
Counters
counter shows the length at the end of the field. maxlength is the browser's hard limit, where softLimit is a line the reader may cross: the text is never cut, the counter turns red and the field goes into error through the native validity. The prop counts characters, as on VTextarea; on VFileInput the same name counts files and their size.
The browser refuses the twenty-first character.
Type past forty and the field goes into error instead.
Pattern
There is no pattern prop: the native attribute reaches the input through fallthrough, along with inputmode, name and everything else a form needs. The field turns red through :user-invalid, once the reader has left it.
Five digits.
API
Props
| Prop | Type | Default |
|---|---|---|
size | InputSize'sm' | 'md' | 'lg' | 'md' |
| The height of the field: 32, 40 or 48 pixels. | ||
compact | boolean | false |
| Takes 4px off the height, leaving the padding, the text and the icons as they are. | ||
type | InputType'text' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'url' | 'text' |
The native type of the input, which is also what tells a phone which keyboard to offer: a numeric pad for number, an @ key for email. | ||
invalid | boolean | false |
| Marks the field as invalid whatever the browser thinks. This is the route for a rule only the server can check; anything the browser can validate on its own already colours the field without it. | ||
disabled | boolean | false |
| Makes the field unusable, greyed out through the colour tokens. | ||
readonly | boolean | false |
Shows the value without allowing it to be changed. The field can still be focused and copied from, and it hides the clear button unless clearVisible answers that question explicitly. | ||
noTyping | boolean | false |
| Refuses the keyboard without drawing the field as read-only: the native attribute is set, but the field keeps its ordinary look and its clear cross. For a field whose value comes from somewhere else, a picker or a file dialog, and which is no less editable for it. | ||
label | string | none |
| The label above the field, tied to it so that clicking it focuses the field. | ||
hint | string | none |
| A line of help under the field. It is tied to the input for assistive technology, so it is read out along with the label. | ||
iconStart | IconSource | none |
An icon inside the field, at the start. It is decorative until a @click:icon-start listener is attached, at which point it becomes a real button and needs iconStartLabel. | ||
iconEnd | IconSource | none |
The same at the end of the field. The #end slot replaces it, and the loading spinner takes its place while it turns. | ||
iconStartLabel | string | none |
| What the start icon does, in words, once it is clickable. | ||
iconEndLabel | string | none |
| What the end icon does, in words, once it is clickable. | ||
loading | boolean | false |
| Shows a spinner at the end of the field, in place of the end icon or slot. | ||
loadingText | string | none |
| What screen readers announce while the spinner turns. It falls back to the design system dictionary. | ||
clearable | boolean | false |
| Offers a cross that empties the field. It appears when there is something to clear and the field can be edited. | ||
clearVisible | boolean | none |
| Decides whether the cross is shown, instead of letting the field work it out from its own content. It exists for the components built on this one, where what there is to clear is not the text: VCombobox holds its selection as chips beside the field, and a read-only date or time picker changes its value through a panel rather than by typing. | ||
clearLabel | string | none |
| What the clear button does, in words. It falls back to the design system dictionary. | ||
maxlength | number | none |
| The maximum number of characters. By default this is the browser's own limit, which simply refuses anything beyond it. | ||
softLimit | boolean | false |
| Turns that limit into a soft one: the reader may type past it, and the field goes into error instead of silently refusing the keystrokes. It is reported through the native validity, so a form cannot be submitted over the limit. | ||
counter | boolean | false |
| Shows how much has been typed, at the end of the field: 12/80 against a limit, or just 12 without one. | ||
v-model | string | number | '' |
The value, typed as text or a number rather than text alone. On an <input type="number"> Vue converts the value to a number by itself, so a string-only model would hand a number back to a consumer who passed a string in. | ||
Events
| Event | Type |
|---|---|
click:icon-start | [event: MouseEvent] |
| The start icon was pressed. Attaching this listener is what turns it into a button. | |
click:icon-end | [event: MouseEvent] |
| The end icon was pressed. Attaching this listener is what turns it into a button. | |
clear | [] |
| The clear button was pressed. The value has already been emptied. | |
Slots
| Slot | Type |
|---|---|
start | {} |
Content at the start of the field, rendered after iconStart rather than in its place. | |
value-end | {} |
| Controls of your own inside the field, placed before the field's own: the clear cross and the end icon. It is where something that acts on the value belongs, so that the reading order and the tab order agree. | |
end | {} |
Content at the end of the field, which replaces iconEnd. It is hidden while the field is loading, the spinner taking that place. | |
Types
The types the tables above name, written as the library declares them. The ones carrying export can be imported from vectis-ui to type your own code; the others are the shape of what a slot hands out.
export interface BuiltinIcon {
name: string
paths: readonly [string] | readonly [string, string]
}export type IconRender =
| { path: string; viewBox?: string }
| { component: Component; props?: Record<string, unknown> }
| { src: string }
| { text: string; class?: string }
| { class: string }export type IconSource = string | BuiltinIcon | IconRender