Components
< template >
< v-row >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField v-model = " name " : label = " $t ( ' ui.demo.fields.name ' ) " />
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField v-model = " company " : label = " $t ( ' ui.demo.fields.company ' ) " optional />
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
v-model = " username "
: label = " $t ( ' ui.demo.fields.username ' ) "
: hint = " $t ( ' ui.demo.fields.usernameHint ' ) "
persistent-hint
/>
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
v-model = " website "
type = " url "
: label = " $t ( ' ui.demo.fields.website ' ) "
: error-messages = " $t ( ' ui.demo.fields.websiteError ' ) "
/>
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
: model-value = " $t ( ' ui.demo.fields.readonlyValue ' ) "
: label = " $t ( ' ui.demo.fields.readonly ' ) "
readonly
/>
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
: model-value = " $t ( ' ui.demo.fields.disabledValue ' ) "
: label = " $t ( ' ui.demo.fields.disabled ' ) "
disabled
/>
</ v-col >
</ v-row >
</ template >
< script setup lang = " ts " >
const name = ref ( '' )
const company = ref ( '' )
const username = ref ( '' )
const website = ref ( ' example ' )
</ script >
< template >
< v-row >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
v-model = " email "
type = " email "
: label = " $t ( ' ui.demo.fields.email ' ) "
prepend-inner-icon = " mail "
autocomplete = " email "
clearable
/>
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
v-model = " amount "
: label = " $t ( ' ui.demo.fields.amount ' ) "
: prefix = " currencySymbol "
: suffix = " currencyCode "
inputmode = " decimal "
/>
</ v-col >
< v-col cols = " 12 " md = " 6 " >
< BaseTextField
v-model = " taxId "
: label = " $t ( ' ui.demo.fields.taxId ' ) "
: info = " $t ( ' ui.demo.fields.taxIdInfo ' ) "
/>
</ v-col >
</ v-row >
</ template >
< script setup lang = " ts " >
const email = ref ( '' )
const amount = ref ( '' )
const taxId = ref ( '' )
const { currencyCode , currencySymbol } = useNumberFormat ()
</ script >
Rules come from useFormRules() and the submit from useFormSubmit(). Submit the empty form to see the error, then type a valid email.
< template >
< v-form ref = " formRef " class = " d-flex flex-column ga-4 " @submit.prevent = " submit " >
< BaseTextField
v-model = " values . email "
type = " email "
: label = " $t ( ' ui.demo.fields.email ' ) "
: rules = " [ rules . required (), rules . email ()] "
autocomplete = " email "
hide-details = " auto "
/>
< BaseButton
button-type = " primary "
type = " submit "
class = " align-self-start "
: loading = " isSubmitting "
>
{{ $t('ui.demo.save') }}
</ BaseButton >
< BaseFormFeedback : success = " isSuccess ? $t ( ' ui.demo.alerts.success ' ) : undefined " />
</ v-form >
</ template >
< script setup lang = " ts " >
const rules = useFormRules ()
const values = reactive ({ email : '' })
const { formRef , isSubmitting , isSuccess , submit } = useFormSubmit ( values , async () => {
await new Promise (( resolve ) => setTimeout ( resolve , 600 ))
})
</ script >
The Forms guide explains rules, server errors and submit states in detail.
It also accepts every prop, slot and event of v-text-field , which it passes through. Props
labelstring— The visible label above the field, linked to it with for and aria-labelledby. input-idstring— A fixed id for the input. One is generated with useId() when you leave it out. optionalboolean— Adds “(optional)” after the label. Never mark required fields. infoBaseInputInfo— A help popover next to the label: a text or a list of { title, text }.
Slots
#label-append—Content at the end of the label row, such as a “Forgot it?” link.
The look of every field comes from useInputStyles() (variant, density, radius and colour). Change it there to restyle all of them at once.
The label is always visible and linked to the input. Error messages are announced through aria-describedby and the field gets aria-invalid. Set type, inputmode and autocomplete so phones show the right keyboard and browsers can autofill.