Keyboard shortcut: Ctrl + K
Get started

Input

VInput is a single-line field with optional label, help text, icons and actions.

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'

const email = ref('')
</script>

<template>
  <VInput v-model="email" label="Email" placeholder="[email protected]" />
</template>

Examples

Label and hint

label names the field. hint adds help text linked through aria-describedby.

vue

Shown next to everything you publish.

<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'

const name = ref('')
</script>

<template>
  <VInput
    v-model="name"
    label="Display name"
    hint="Shown next to everything you publish."
    placeholder="Ada Lovelace"
  />
</template>

Sizes

size adjusts the height, padding, text and icons.

vue
<script setup lang="ts">
import { VInput } from 'vectis-ui'
</script>

<template>
  <div class="grid">
    <VInput size="sm" label="Small" placeholder="32px" />
    <VInput size="md" label="Medium" placeholder="40px" />
    <VInput size="lg" label="Large" placeholder="48px" />
  </div>
</template>

<style scoped>
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--vectis-space-4);
}
</style>

Icons

Add decorative icons with iconStart and iconEnd, or custom content with #start and #end.

vue

This handle is free.

<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'
import { check_circle as checkCircle, search } from 'vectis-ui/icons'

const query = ref('')
const handle = ref('ada')
</script>

<template>
  <div class="fields">
    <VInput
      v-model="query"
      label="Search"
      :icon-start="search"
      placeholder="Orders, people, files"
    />
    <VInput v-model="handle" label="Handle" :icon-end="checkCircle" hint="This handle is free." />
  </div>
</template>

<style scoped>
.fields {
  display: grid;
  gap: var(--vectis-space-4);
}
</style>

Clear button

clearable adds a button that empties the field and restores focus. Use clearVisible to control its visibility.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'
import { search } from 'vectis-ui/icons'

const query = ref('wool socks')
</script>

<template>
  <VInput v-model="query" label="Search" :icon-start="search" clearable />
</template>

States

disabled blocks interaction. readonly allows focus and copying. invalid marks an error, and error also shows its message in place of the hint. loading shows a spinner while leaving the field editable.

vue

That handle is already taken.

Loading…
<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'

const handle = ref('ada')
const query = ref('metro')
</script>

<template>
  <div class="fields">
    <VInput label="Disabled" model-value="Not editable" disabled />
    <VInput label="Read-only" model-value="[email protected]" readonly />
    <VInput v-model="handle" label="Invalid" invalid hint="That handle is already taken." />
    <VInput v-model="query" label="Loading" loading />
  </div>
</template>

<style scoped>
.fields {
  display: grid;
  gap: var(--vectis-space-4);
}
</style>

Clickable icons

Attach @click:icon-start or @click:icon-end to make an icon a button. Provide its accessible name with iconStartLabel or iconEndLabel.

vue

Press the magnifier to search.

<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'
import { search, swap_vert as swapVert } from 'vectis-ui/icons'

const query = ref('wool socks')
const searched = ref('')

const amount = ref('120.00')
const currency = ref<'EUR' | 'USD'>('EUR')

function switchCurrency() {
  currency.value = currency.value === 'EUR' ? 'USD' : 'EUR'
}
</script>

<template>
  <div class="fields">
    <VInput
      v-model="query"
      label="Search"
      :icon-end="search"
      icon-end-label="Run the search"
      :hint="searched ? `Searched for ${searched}.` : 'Press the magnifier to search.'"
      @click:icon-end="searched = query"
    />

    <VInput
      v-model="amount"
      :label="`Amount in ${currency}`"
      :icon-start="swapVert"
      icon-start-label="Switch currency"
      @click:icon-start="switchCurrency"
    />
  </div>
</template>

<style scoped>
.fields {
  display: grid;
  gap: var(--vectis-space-4);
}
</style>

Character counter

counter displays the character count. With maxlength, softLimit allows typing past the limit and reports a native validation error.

vue
0/20

The browser refuses the twenty-first character.

42/40

Type past forty and the field goes into error instead.

<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'

const nickname = ref('')
const headline = ref('A design system that leans on the platform')
</script>

<template>
  <div class="fields">
    <VInput
      v-model="nickname"
      label="Nickname"
      hint="The browser refuses the twenty-first character."
      counter
      :maxlength="20"
    />

    <VInput
      v-model="headline"
      label="Headline"
      hint="Type past forty and the field goes into error instead."
      counter
      :maxlength="40"
      soft-limit
    />
  </div>
</template>

<style scoped>
.fields {
  display: grid;
  gap: var(--vectis-space-4);
}
</style>

Native validation

Native attributes such as pattern, inputmode and name are forwarded to the input. class and style apply to the wrapper.

vue

Five digits.

<script setup lang="ts">
import { ref } from 'vue'
import { VInput } from 'vectis-ui'

const postcode = ref('')
</script>

<template>
  <VInput
    v-model="postcode"
    label="Postcode"
    hint="Five digits."
    pattern="[0-9]{5}"
    inputmode="numeric"
    title="Five digits, 75001 for instance."
  />
</template>

API

Props

PropTypeDefault
sizeInputSize'sm' | 'md' | 'lg''md'
Field size. Overridden when VInputGroup sets size.
typeInputType'text' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'url''text'
Native input type.
invalidbooleanfalse
Sets aria-invalid and the error style. Does not block form submission by itself.
disabledbooleanfalse
Disables the field, removing it from Tab navigation and form submission.
readonlybooleanfalse
Prevents editing while allowing focus and copying. Hides the clear button unless clearVisible overrides it.
noTypingbooleanfalse
Prevents typing through native readonly without the read-only style. Keeps clearing available, for fields edited through a picker.
labelstringnone
Visible label linked to the input. When omitted, provide aria-label or aria-labelledby.
hintstringnone
Help text below the field, linked through aria-describedby.
errorstringnone
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears.
requiredbooleanfalse
Adds an asterisk after the label and passes required to the field.
hideLabelbooleanfalse
Hides the label visually while keeping it as the accessible name.
labelPositionFieldLabelPosition'top' | 'start''top'
Places the label above the field or beside it.
iconStartIconSourcenone
Start icon. Becomes a button with @click:icon-start; then requires iconStartLabel.
iconEndIconSourcenone
End icon. Becomes a button with @click:icon-end; then requires iconEndLabel. Replaced by #end or the loading spinner.
iconStartLabelstringnone
Accessible name of the start icon button.
iconEndLabelstringnone
Accessible name of the end icon button.
loadingbooleanfalse
Replaces the end icon or #end content with a spinner. Does not disable the field.
loadingTextstringnone
Accessible spinner text. Defaults to the library dictionary.
clearablebooleanfalse
Adds a clear button when the field is non-empty and editable, unless clearVisible overrides visibility. Hidden when disabled.
clearVisiblebooleannone
Overrides the content and read-only checks for clear-button visibility. Requires clearable and an enabled field.
clearLabelstringnone
Accessible name of the clear button. Defaults to the library dictionary.
maxlengthnumbernone
Native character limit. Not applied as a native attribute with softLimit.
softLimitbooleanfalse
Allows exceeding maxlength and sets a native validation error until the value is within the limit.
counterbooleanfalse
Character count inside the field: 12/80 with a limit, or 12 without one.
v-modelstring | number''
Field value, a string or number. With type="number", Vue converts numeric input to a number. An empty field uses an empty string.

Events

EventType
click:icon-start[event: MouseEvent]
Emitted when the start icon button is activated. Receives a MouseEvent.
click:icon-end[event: MouseEvent]
Emitted when the end icon button is activated. Receives a MouseEvent.
clear[]
Emitted after the clear button resets the value to an empty string.

Slots

SlotType
start{}
Content after iconStart. Does not replace the icon.
value-end{}
Content after the value and counter, before the clear button and end icon.
control{ controlProps: InputControlProps; }
Control replacing the input, for composed fields. Bind the received controlProps on it: id, field class, ARIA links and forwarded attributes.
end{}
Content replacing iconEnd. Hidden while loading.
meta{ id: string; }
Content at the end of the hint line, such as a counter. Bind its id, which joins the field description.

Types

Types used in the API tables. Import exported types from vectis-ui.

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
export type InputControlProps = {
  id: string
  class: string
  disabled: boolean
  'aria-invalid'?: 'true'
  'aria-describedby'?: string
} & Record<string, unknown>