Skip to content

Input API Reference ​

Props ​

PropTypeDefaultDescription
prependBooleanfalseShow prepend button
prependInnerBooleanfalseShow inner prepend button
labelString''Label for the input
appendInnerBooleanfalseShow inner append button
appendBooleanfalseShow append button
clearableBooleanfalseAllow clearing the input
hideDetailsBooleanfalseHide validation details
hintString-Hint message for the input
persistentHintBooleanfalseAlways show hint message
loadingBooleanfalseShow loading state
disabledBooleanfalseDisable the input
readonlyBooleanfalseMake the input read-only
placeholderString''Placeholder text
typeString'text'Input type (text, email, password, etc.)
persistentDetailsBooleanfalseAlways show validation details
modelValueString/Number/Object/Array-v-model binding value
valueString/Number/Object/Array-Alternative to modelValue
rulesArray[]Validation rules
hideSpinButtonsBooleanfalseHide spin buttons for number inputs

Events ​

The component emits many standard DOM events, including:

EventPayloadDescription
update:modelValueValueEmitted when input value changes
prepend:clickEventEmitted when prepend button is clicked
prependInner:clickEventEmitted when inner prepend button is clicked
clear:clickEventEmitted when clear button is clicked
append:clickEventEmitted when append button is clicked
appendInner:clickEventEmitted when inner append button is clicked
validateBoolean, Value, MessageEmitted when validation occurs
focus, blur, input, changeEventStandard form events
keydown, keyup, keypressEventKeyboard events
click, dblclick, mousedown, etc.EventMouse events

Slots ​

SlotPropsDescription
prepend{ click }Content before the input
prependInner{ click }Content inside the input, at the beginning
input-fieldVarious propsCustom input field
append-inner{ click, changeInternalType, internalType }Content inside the input, at the end
append{ click }Content after the input
details{ errorMessage, hint }Custom validation details
loading-Custom loading indicator

Methods ​

The component exposes these methods via template refs:

MethodDescription
validate()Manually trigger validation
setInternalValue(value)Set the input value programmatically

Example Usage ​

vue
<template>
  <OInput
    v-model="email"
    label="Email Address"
    type="email"
    :rules="[
      { rule: 'required', message: 'Email is required' },
      { rule: 'email', message: 'Please enter a valid email' }
    ]"
    :clearable="true"
    :appendInner="true"
    @validate="handleValidation"
  />
</template>

<script setup>
import { ref } from 'vue'
import { OInput } from 'your-component-library'

const email = ref('')

const handleValidation = (isValid, value, message) => {
  console.log('Validation result:', isValid, value, message)
}
</script>

Validation Rules ​

The component supports these built-in validation rules:

  • required: Field must not be empty
  • email: Field must be a valid email address
  • min: Field must have a minimum length
  • max: Field must have a maximum length
  • numeric: Field must contain only numbers
  • alpha: Field must contain only letters
  • alphaNumeric: Field must contain only letters and numbers
  • phone: Field must be a valid phone number
  • url: Field must be a valid URL

You can also create custom validation rules using the custom rule type and providing a validator function.