Skip to content
Latestv1.0.63

Input ​

Input content via mouse or keyboard, the most basic form field wrapper.

Basic Usage ​

Basic Usage

Disabled State ​

Disabled State

Clearable ​

Clearable

Password Box ​

Password Box

Input with Icons ​

Input with Icons

Textarea ​

Textarea

Autosize Textarea ​

Autosize

Composite Input ​

Add an element before or after the input field, typically a label or a button.

Composite Input

Input Length Limit ​

Word Limit

Different Sizes ​

Different Sizes

Formatted Input ​

Formatted

Visual Variants ​

Use the variant prop to switch between four visual styles: default (with border), filled (filled background), borderless (no border), underlined (bottom line only).

Visual Variants

Loading State ​

Set loading to true to show a spinning loading icon in the suffix area. Commonly used for async username checks, real-time search, etc.

Loading State

Independent Status Color ​

Use status to apply success, warning, or error border colors without relying on a Form/FormItem wrapper.

Independent Status

Select On Focus ​

With select-on-focus, clicking or Tab-keying into the input will auto-select all text inside. Perfect for numeric editing or table cell editing.

Select On Focus

Clear On Escape ​

With clear-on-escape, pressing Esc immediately clears the input content. Works best combined with clearable.

Clear On Escape

Prefix/Suffix String & Native Datalist ​

The prefix/suffix props accept plain strings (e.g. currency symbols, units) without needing slots. The list prop binds a native <datalist> id for local autocomplete suggestions.

Prefix/Suffix String & Datalist

Custom Word Count ​

Use count-config's calculate function to define custom length calculation logic, e.g. CJK characters count as 2 bytes.

Custom Word Count

Use in Nuxt ​

YhInput can be used directly in Nuxt 3/4. SSR renders a stable input structure first, and client-side hydration continues focus, clear, counter, and other interaction behavior.

Use in Nuxt

SSR Notes:

  • ✅ Basic input and textarea modes are fully supported.
  • ✅ Style and layout are consistent between server and browser.
  • ✅ Dynamic ID generation is SSR-safe (based on useId).
  • ⚠️ autofocus attribute only takes effect after client-side activation.

SSR Safety

The Input component is optimized for SSR, especially its ID generation mechanism, ensuring consistency between server rendering and client activation, effectively avoiding attribute mismatch errors.

API ​

Props ​

PropDescriptionTypeDefault
model-value / v-modelBinding valuestring | number—
typeType'text' | 'password' | 'textarea' | 'number' | 'email' | 'url' | 'tel' | 'search''text'
sizeInput size'large' | 'default' | 'small''default'
placeholderPlaceholder textstring—
variantVisual variant style'default' | 'filled' | 'borderless' | 'underlined''default'
statusIndependent status color, without relying on FormItem'' | 'success' | 'warning' | 'error'''
loadingWhether to show loading statebooleanfalse
disabledWhether to disablebooleanfalse
readonlyWhether to set read-onlybooleanfalse
clearableWhether it is clearablebooleanfalse
clear-on-escapeWhether pressing Esc clears the inputbooleanfalse
select-on-focusWhether to auto-select all text on focusbooleanfalse
show-passwordWhether to show password toggle iconbooleanfalse
show-word-limitWhether to show word countbooleanfalse
count-configCustom word count configuration{ calculate?: (value: string) => number }—
maxlengthMaximum input lengthnumber | string—
minlengthMinimum input lengthnumber | string—
prefix-iconPrefix iconstring | Component—
suffix-iconSuffix iconstring | Component—
clear-iconClear iconstring | Component—
prefixPrefix text string (shortcut for #prefix slot)string—
suffixSuffix text string (shortcut for #suffix slot)string—
listNative list attribute, binds a datalist element idstring—
autofocusAutofocus on mountingbooleanfalse
autocompleteNative autocomplete attributestring'off'
nameNative name attributestring—
formNative form attributestring—
idInput IDstring—
aria-labelNative aria-label attributestring—
tabindexInput tabindexstring | number—
validate-eventWhether to trigger form validation on inputbooleantrue
input-styleInput inline stylestring | object—
label(Deprecated) Native aria-label attribute, suggest use aria-labelstring—
inputmodeNative inputmode attributestring—
model-modifiersv-model modifiersobject—
formatterFormat function (for display)(value: string | number) => string—
parserParse function (for updating value)(value: string) => string—
rowsTextarea rows (effective for type="textarea")number2
autosizeAutosize height (effective for type="textarea")boolean | { minRows?: number; maxRows?: number }false
theme-overridesComponent-level theme overridesComponentThemeVarsundefined
resizeWhether to allow resizing (effective for type="textarea")'none' | 'both' | 'horizontal' | 'vertical'—

Events ​

Event NameDescriptionCallback Parameters
update:modelValueTriggered when binding value updates(value: string | number) => void
inputTriggered when input value changes(value: string | number) => void
changeTriggered on blur or Enter press(value: string | number) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered on clicking clear button() => void
keydownTriggered on key down(event: KeyboardEvent) => void
keyupTriggered on key up(event: KeyboardEvent) => void
compositionstartTriggered when IME starts input(event: CompositionEvent) => void
compositionupdateTriggered during IME input(event: CompositionEvent) => void
compositionendTriggered when IME starts finishes(event: CompositionEvent) => void

Slots ​

Slot NameDescription
prefixHeader content of input
suffixFooter content of input
prependPrepend content (composite input)
appendAppend content (composite input)
clearIconCustom clear icon
loadingIconCustom loading icon

Expose ​

NameDescriptionType
refInput DOM elementHTMLInputElement | HTMLTextAreaElement | undefined
wrapperRefWrapper element DOMHTMLElement | undefined
focusFocus the input() => void
blurBlur the input() => void
selectSelect text in input() => void
clearClear input content() => void
textLengthCurrent display length (result from countConfig if provided)number

Theme Variables ​

YhInput supports themeOverrides. The component itself consumes the following CSS variables:

VariableDescriptionDefault
--yh-input-heightInput heightvar(--yh-component-size-default)
--yh-input-font-sizeFont sizevar(--yh-font-size-base)
--yh-input-paddingInput padding0 var(--yh-spacing-md)
--yh-input-border-colorBorder colorvar(--yh-border-color)
--yh-input-hover-border-colorHover border colorvar(--yh-border-color-hover)
--yh-input-focus-border-colorFocus border colorvar(--yh-color-primary)
--yh-input-bg-colorBackground colorvar(--yh-fill-color-blank)

Type Exports ​

NameDescription
YhInputPropsProps type for YhInput
YhInputEmitsEmits type for YhInput
YhInputSlotsSlots type for YhInput
YhInputExposeExpose type for YhInput
YhInputTypeInput type union
YhInputSizeInput size union
YhInputVariantVisual variant union
YhInputStatusStatus union
YhInputCountConfigWord count config type
YhInputInstancePublic instance type for YhInput

Released under the MIT License.