InputText

InputText is an extension to standard input element.


import InputText from 'primevue/inputtext';

InputText is used as a controlled input with v-model properties.


<InputText type="text" v-model="value" />

Icons can be placed inside an input element by wrapping both the input and the icon with an element that has either .p-input-icon-left or .relative class.


<span class="relative">
    <i class="pi pi-search absolute top-2/4 -mt-2 left-3 text-surface-400 dark:text-surface-600" />
    <InputText v-model="value1" placeholder="Search" class="pl-10" />
</span>

<span class="relative">
    <i class="pi pi-spin pi-spinner absolute top-2/4 -mt-2 right-3 text-surface-400 dark:text-surface-600" />
    <InputText v-model="value2" class="pr-10" />
</span>

InputText provides small and large sizes as alternatives to the standard.


<InputText v-model="value1" type="text" size="small" placeholder="Small" />
<InputText v-model="value2" type="text" placeholder="Normal" />
<InputText v-model="value3" type="text" size="large" placeholder="Large" />

An advisory text can be defined with the semantic small tag.

Enter your username to reset your password.

<div class="flex flex-col gap-2">
    <label for="username">Username</label>
    <InputText id="username" v-model="value" aria-describedby="username-help" />
    <small id="username-help">Enter your username to reset your password.</small>
</div>

Invalid state style is added using the .p-invalid class to indicate a failed validation.


<InputText v-model="value" invalid />

When disabled is present, the element cannot be edited and focused.


<InputText v-model="value" disabled placeholder="Disabled" />

Screen Reader

InputText component renders a native input element that implicitly includes any passed prop. Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, aria-label props.


<label for="firstname">Firstname</label>
<InputText id="firstname" />

<span id="lastname">Lastname</span>
<InputText aria-labelledby="lastname" />

<InputText aria-label="Age"/>

Keyboard Support

KeyFunction
tabMoves focus to the input.