InputField
Form field component for user text input with validation support.
Component
Help text example
Props
| Props | Required | Default | Type |
|---|---|---|---|
id | true | — | string |
label | — | — | string |
type | — | 'text' | AllowedInputType |
placeholder | — | 'Placeholder' | string |
helpText | — | — | string |
helpTextPosition | — | Position.BOTTOM | Position |
icon | — | — | string |
suffixIcon | — | — | string |
linkText | — | — | string |
linkUrl | — | — | string |
size | — | InputSize.MD | InputSize |
modelValue | — | '' | string | number | null |
validator | — | — | Function |
error | — | — | string |
maxLength | — | — | number |
filterAlphabetic | — | — | boolean |
permitNegativeNumber | — | — | boolean |
hasShowPasswordButton | — | — | boolean |
min | — | — | string |
max | — | — | string |
step | — | — | string |
pattern | — | — | string |
readonly | — | — | boolean |
autocomplete | — | 'off' | string |
autofocus | — | false | boolean |
disabled | — | false | boolean |
required | — | false | boolean |
showOptionalLabel | — | true | boolean |
optionalLabel | — | — | string |
transparent | — | false | boolean |
inputClass | — | — | string |
Usage
id
Sets the id of the field.
<template>
<InputField id="field-id" />
</template>
label
Sets the label of the field.
<template>
<InputField label="Label text" />
</template>
type
Sets the type of the input field. It uses the AllowedInputType type.
For the rest of native HTML input types, please use the specific components provided by AirUI.
<template>
<InputField type="text" />
</template>
placeholder
Sets the placeholder text of the input field.
<template>
<InputField placeholder="Placeholder" />
</template>
helpText
Sets the help text displayed below the input field.
<template>
<InputField helpText="Help text example" />
</template>
helpTextPosition
Sets the position of the help text relative to the input field. It uses the Position enum.
<template>
<InputField helpTextPosition="top" helpText="Appears above the field" />
</template>
Options
| Value | Description |
|---|---|
TOP | top |
BOTTOM | bottom |
icon
Sets the icon of the input field.
<template>
<InputField icon="mdi:account" />
</template>
suffixIcon
Sets the suffix icon of the input field.
<template>
<InputField suffixIcon="mdi:eye" />
</template>
linkText
Sets the link text of the input field when the type is password.
<template>
<InputField linkText="Forgot password?" />
</template>
linkUrl
Sets the link URL of the input field when the type is password.
<template>
<InputField linkUrl="/reset-password" />
</template>
size
Sets the size of the input field. It uses the InputSize enum.
<template>
<InputField :size="InputSize.MD" />
</template>
Options
| Value | Description |
|---|---|
MD | md |
LG | lg |
modelValue
Sets the value of the input field.
<template>
<InputField v-model="inputValue" />
</template>
<script setup lang="ts">
const inputValue = ref<string | number | null>('')
</script>
validator
Sets the validator function for the field, which controls its internal validation state.
It uses the validateField utility to perform required field validation.
<template>
<InputField :validator="validateField" />
</template>
error (v-model:error)
Sets the error message of the field. This prop is bindable via v-model:error, allowing two-way syncing of the validation state.
<template>
<InputField v-model:error="errorMessage" />
</template>
maxLength
Sets the maximum length of the input field.
<template>
<InputField :maxLength="10" />
</template>
filterAlphabetic
Sets whether to filter alphabetic characters in the input field.
<template>
<InputField filterAlphabetic />
</template>
permitNegativeNumber
Sets whether to permit negative numbers in the input field (only for type number).
<template>
<InputField permitNegativeNumber />
</template>
hasShowPasswordButton
Sets whether to show the "show password" button (only for type password).
<template>
<InputField hasShowPasswordButton />
</template>
min
Sets the minimum value of the input field (only for type number).
<template>
<InputField :min="0" />
</template>
max
Sets the maximum value of the input field (only for type number).
<template>
<InputField :max="100" />
</template>
step
Sets the step value of the input field (only for type number).
<template>
<InputField :step="1" />
</template>
pattern
Sets the pattern attribute of the input field.
<template>
<InputField pattern="[A-Za-z]{3}" />
</template>
readonly
Sets the readonly state of the field.
<template>
<InputField readonly />
</template>
autocomplete
Sets the autocomplete attribute of the input field.
<template>
<InputField autocomplete="on" />
</template>
autofocus
Sets the autofocus state of the field.
<template>
<InputField autofocus />
</template>
disabled
Sets the disabled state of the field.
<template>
<InputField disabled />
</template>
required
Sets the required state of the field.
<template>
<InputField required />
</template>
showOptionalLabel
When the field is not required, shows an "(optional)" hint next to the label. Set to false to hide it.
<template>
<InputField label="Middle name" :showOptionalLabel="false" />
</template>
The hint text defaults to a global setting that can be overridden project-wide, and can also be overridden per field with the optionalLabel prop.
optionalLabel
Overrides the "(optional)" hint text for this specific field, taking priority over the global default.
<template>
<InputField label="Middle name" optionalLabel="(not required)" />
</template>
transparent
When true, removes the default bg-background-container-surface background from the input container, making it transparent.
<template>
<InputField transparent />
</template>
inputClass
Applies additional CSS classes directly to the <input> element, appended last so they can override other classes.
<template>
<InputField inputClass="text-right font-mono" />
</template>