Skip to content

InputText

Basic Usage

vue
<script setup>
import { InputText } from '@8ctavio/vergil/components'
import { useModel } from '@8ctavio/vergil'
const text = useModel('')
</script>

<template>
    <InputText v-model="text" label="Text Input"/>
</template>

Props

Placeholder
placeholder: string

vue
<InputText placeholder="Text Input"/>

Max
max: string

The maximum string length that can be entered into the text input.

vue
<InputText max="10" placeholder="Up to 10 characters"/>

Text align
text-align: ('left' | 'center' | 'right') = 'left'

vue
<InputText text-align="left" placeholder="Left"/>
<InputText text-align="center" placeholder="Center"/>
<InputText text-align="right" placeholder="Right"/>

Type
type: ('text' | 'password') = 'text'

vue
<InputText type='text' placeholder="Username"/>
<InputText type='password' placeholder="Password"/>

Autoselect
boolean

Selects InputText's text when focused.

vue
<InputText value="Focus me!" autoselect/>

Prefix and Suffix
prefix: string
suffix: string

vue
<InputText prefix="Prefix" suffix="Suffix"/>

Prefix

Suffix

Icons
icon[-left]: string
icon-right: string

vue
<InputText icon="person" icon-right="lock"/>
<!-- or -->
<InputText icon-left="person" icon-right="lock"/>
personlock

Side Buttons
btn-before: object
btn-after: object

The btn-before and btn-after props receive objects representing the props for Btn components to be displayed before and after the input field area, respectively.

The following Btn props are ignored from the btn-before and btn-after props, and are rather taken from the InputField's props:

  • theme
  • size
  • radius
  • spacing

The Btn disabled prop is bound to the InputField disabled prop. That is, both btn-before and btn-after accept a disabled prop, but if the InputField is disabled, then the side buttons will also get disabled.

vue
<script setup>
const btnBeforeProps = {
    icon: 'bolt'
}
const btnAfterProps = {
    icon: 'science'
}
</script>

<template>
    <InputText :btn-before="btnBeforeProps" :btn-after="btnAfterProps"/>
</template>

Float label
float-label: boolean

vue
<InputText label="Text Input" float-label/>

NOTE

float-label only works if the placeholder, description, prefix, and icon[-left] props are unset.

Space evenly
boolean

When set to true, InputText's value is trimmed and consecutive whitespace characters (/\s+/) are replaced with a single space character (" ") when the Enter key is pressed or the element loses focus.

vue
<InputText space-evenly/>

Underline
underline: boolean

Theme
theme: theme = 'brand'

Size
size: ('xs' | 'sm' | 'md' | 'lg' | 'xl') = 'md'

Radius
radius: ('none' | 'sm' | 'md' | 'lg' | 'full') = 'md'

Spacing
spacing: ('compact' | 'expanded') = ''

Disabled
disabled: boolean

Enter validation
prevent-enter-validation: boolean

By default, InputText's is automatically validated when the keydown event is fired with the 'Enter' key. However, validation on enter-key press, is disabled if the underlying input element belongs to a form element, or if the prevent-enter-validation prop is set to true.

Elements

elementtagdescription
input<input>InputText's underlying input element.

Anatomy

<div.form-field.input-text/>

<div.form-field-label-wrapper/>

<label.form-field-label/>

<span.form-field-hint/>

<p.form-field-details.form-field-description/>

<div.input-text-outer/>

<Btn.btn/>

<div.input-text-wrapper/>

<Icon.icon/>

<p/>

<input/>

<label/>

<p/>

<Icon.icon/>

<Btn.btn/>

<p.form-field-details.form-field-help/>

API Reference

Props

proptypedefault
valuestring''
placeholderstring''
maxstring
text-align'left' | 'center' | 'right''left'
type'text' | 'password''text'
autoselectboolean
prefixstring
suffixstring
iconstring
icon-leftstring
icon-rightstring
btn-beforeobject
btn-afterobject
spaceEvenlyboolean
underlineboolean
disabledboolean
labelstring
hintstring
descriptionstring
helpstring
showErrrosboolean
floatLabelboolean
descendantboolean
theme'brand' | 'user' | 'ok' | 'info' | 'warn' | 'danger' | 'neutral''brand'
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
radius'none' | 'sm' | 'md' | 'lg' | 'full''md'
spacing'' | 'compact' | 'extended'''
validatorFunction
eagerValidationboolean
elementsobject
preventEnterValidationboolean
validationDelaynumber300
validationCooldownnumber350

Configuration options

InputText's configuration options allow to overwrite some InputText props' default values and may be overwritten under the inputText root-level configuration option.

inputText.<option>typedefaultglobal
underlineboolean
validationDelaynumber
validationCooldownnumber
themetheme
sizesize
radiusradius
spacingspacing