Skip to content

useInput ​

Base composable for all form inputs. Provides modelValue binding, schema-driven prop resolution, and the updateModelValue / emitModelValue contract that every input component must follow.

File: vue/src/js/hooks/useInput.js


Props Factory ​

js
import { makeInputProps } from '@/hooks/useInput'
PropTypeDefaultDescription
modelValueanynullThe bound value (v-model)
schemaObject{}Schema field definition — label, rules, placeholder, etc.
disabledBooleanfalseDisable the input
readonlyBooleanfalseMake the input read-only
clearableBooleanfalseShow a clear button
labelString''Override the label from the schema
placeholderString''Override the placeholder from the schema
hintString''Hint text shown below the input
densityString'comfortable'Vuetify density (compact, comfortable, default)

Emits Factory ​

js
import { makeInputEmits } from '@/hooks/useInput'
EventPayloadDescription
update:modelValueanyEmitted when the value changes
inputanyEmitted on every keystroke / change

Injects Factory ​

js
import { makeInputInjects } from '@/hooks/useInput'

Provides access to form-level inject keys (parent form context, schema bindings).

Usage ​

js
import { useInput, makeInputProps, makeInputEmits } from '@/hooks/useInput'

const props = defineProps(makeInputProps())
const emit = defineEmits(makeInputEmits())

const { id, boundProps, input, initialValue, updateModelValue, emitModelValue } = useInput(props, emit)

Returns ​

NameTypeDescription
idComputedRef<String>Unique input ID derived from the schema field name
boundPropsComputedRef<Object>Merged props object ready to spread onto the underlying Vuetify input component
inputComputedRef<Object>Resolved schema field with all defaults applied
initialValueanyThe value at mount time, used to detect changes
updateModelValue(value) => voidSet the internal value and emit update:modelValue
emitModelValue(value) => voidEmit update:modelValue without updating internal state (use for pass-through)

Notes ​

  • boundProps automatically merges schema-defined props (label, placeholder, rules, disabled) with explicitly passed props. Explicit props take precedence.
  • All hydrate-backed input components (InputText, InputSelect, etc.) call useInput internally.

See Also ​