Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createInput

Shared form field primitive. Owns validation lifecycle, field state tracking (dirty, pristine, focused, touched), ARIA ID generation, and error merging. Consumed by Input, NumberField, Select, and Combobox internally.


AdvancedApr 4, 2026

Usage

ts
import { createInput } from '@vuetify/v0'
import { ref } from 'vue'

const value = ref('')
const input = createInput({
  value,
  rules: [v => !!v || 'Required'],
})

// Field state
input.isDirty.value      // false (no content)
input.isPristine.value   // true (unchanged)
input.isTouched.value    // false (not interacted)

// Trigger validation
await input.validate()
input.isValid.value      // false
input.errors.value       // ['Required']
input.state.value        // 'invalid'

// Update value
value.value = 'hello'
input.isDirty.value      // true
input.isPristine.value   // false

// Reset
input.reset()
value.value              // '' (initial value)
input.isPristine.value   // true
input.isValid.value      // null (unvalidated)

Architecture

Diagram

Use controls to zoom and pan. Click outside or press Escape to close.

Reactivity

PropertyTypeDescription
valueRef<T>The field value (same ref passed in)
isDirtyReadonly<Ref<boolean>>Has content (via dirty predicate)
isPristineReadonly<Ref<boolean>>Unchanged since mount/reset
isFocusedShallowRef<boolean>Writable — component sets on focus/blur
isTouchedShallowRef<boolean>Writable — component sets after first interaction
isDisabledReadonly<Ref<boolean>>Resolved from disabled option
isReadonlyReadonly<Ref<boolean>>Resolved from readonly option
errorsReadonly<Ref<string[]>>Merged validation + manual errors
isValidReadonly<Ref<boolean | null>>Tri-state: null (unvalidated), true, false
isValidatingReadonly<Ref<boolean>>Async validation in progress
stateReadonly<Ref<InputState>>'pristine' | 'valid' | 'invalid'
MethodDescription
validate()Run rules, returns Promise<boolean>
reset()Restore initial value, clear validation
Tip

isDirty and isPristine are not inverses. A pre-filled form field is dirty AND pristine. A cleared field is not-dirty AND not-pristine.

Generic Types

createInput is generic over the value type:

ts
// String (default) — for text inputs
createInput({ value: ref('') })

// Number | null — for numeric inputs
createInput<number | null>({
  value: ref<number | null>(null),
  dirty: v => v !== null,
  equals: (a, b) => Object.is(a, b),
})

// ID | ID[] — for select inputs
createInput<ID | ID[]>({
  value: ref<ID[]>([]),
  dirty: v => Array.isArray(v) ? v.length > 0 : v != null,
})

API Reference

The following API details are for the createInput composable.

Functions

createInput

(options: InputOptions<T>) => InputContext<T>

Options

value required

Ref<T, T>

Value source — caller owns this ref.

id

ID | undefined

Unique identifier (auto-generated if omitted).

label

string | undefined

Display label.

name

string | undefined

Form field name.

form

string | undefined

Associate with form by ID.

required

boolean | undefined

Whether required.

disabled

MaybeRefOrGetter<boolean> | undefined

Disabled state.

readonly

MaybeRefOrGetter<boolean> | undefined

Readonly state.

rules

(string | FormValidationRule | StandardSchemaV1)[] | undefined

Validation rules.

error

MaybeRefOrGetter<boolean> | undefined

Manual error state override — forces invalid.

errorMessages

MaybeRefOrGetter<MaybeArray<string> | undefined>

Manual error messages — merged with rule-based errors.

dirty

((value: T) => boolean) | undefined

Predicate for "has content".

equals

((a: T, b: T) => boolean) | undefined

Equality check for pristine tracking.

Default: ===

Properties

id

ID

label

string | undefined

name

string | undefined

form

string | undefined

required

boolean | undefined

errorId

string

hasDescription

ShallowRef<boolean>

hasError

ShallowRef<boolean>

value

Ref<T, T>

isDirty

Readonly<Ref<boolean, boolean>>

isFocused

ShallowRef<boolean>

isDisabled

Readonly<Ref<boolean, boolean>>

isReadonly

Readonly<Ref<boolean, boolean>>

isPristine

Readonly<Ref<boolean, boolean>>

isTouched

ShallowRef<boolean>

errors

Readonly<Ref<string[], string[]>>

isValid

Readonly<Ref<boolean | null, boolean | null>>

isValidating

Readonly<Ref<boolean, boolean>>

state

Readonly<Ref<InputState, InputState>>

Methods

validate

() => Promise<boolean>

reset

() => void
Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/