Skip to content

FormInput

Text input with v-model binding and optional debounce.

bash
npm install @vuecs/forms

Basic usage

vue
<script setup lang="ts">
import { VCFormInput } from '@vuecs/forms';
import { ref } from 'vue';

const value = ref('');
</script>

<template>
    <VCFormInput v-model="value" placeholder="Enter your email" />
</template>
css
@import "tailwindcss";
@import "@vuecs/design";

/* Required only if you use the input-group variant (prepend/append). */
@import "@vuecs/forms";

@custom-variant dark (&:where(.dark, .dark *));

Props

PropTypeDefaultDescription
modelValuestring | null | undefinedThe bound value. null/undefined are accepted as the "unset" value (renders empty) for binding nullable entity fields
typestring'text'Native input type
debouncenumber0Debounce input updates by N milliseconds
groupbooleanfalseRender with input-group prepend/append wrappers
groupPrepend / groupAppendbooleanfalseShow prepend/append addon slots
groupPrependContent / groupAppendContentstringInline addon content (alternative to slots)

placeholder, disabled, etc. are forwarded to the native <input> via attrs.

Slots

SlotSlot propsDescription
groupPrepend{ class, tag }Custom prepend addon markup. class is the resolved groupPrepend theme class; tag is the suggested wrapper tag ('div'). Replaces the groupPrependContent default
groupAppend{ class, tag }Custom append addon markup. class is the resolved groupAppend theme class; tag is the suggested wrapper tag ('div'). Replaces the groupAppendContent default

Input group

When a prepend and/or append is present (via the groupPrepend / groupAppend props or the #groupPrepend / #groupAppend slots), the input automatically squares the corner(s) touching the addon so the group reads as one seamless control — no consumer override needed.

The squared corners are theme-owned via two formInput theme classes, applied to the <input> in addition to root:

SlotApplied whentheme-tailwind value
rootGroupStarta prepend is presentrounded-l-none
rootGroupEndan append is presentrounded-r-none

Override them per instance via :theme-class, or globally via theme overrides, to change how the seam is squared.

Events

EventPayloadDescription
update:modelValuestring | numberv-model update

See also

Released under the Apache 2.0 License.