Skip to content

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.

Http://
.com
1
1
Composite Input

Input Length Limit

0 / 10
0 / 100
Word Limit

Different Sizes

Different Sizes

Formatted Input

Actual internal value:
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.

$USD
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.

0 / 20
Custom Word Count

Use in Nuxt

Input fully supports Nuxt 3/4 SSR rendering. When used in a Nuxt project, the component is automatically imported.

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
resizeWhether to allow resizing (effective for type="textarea")'none' | 'both' | 'horizontal' | 'vertical'

Events

Event NameDescriptionCallback Parameters
update:modelValueTriggered when binding value updates(value: string) => void
inputTriggered when input value changes(value: string) => void
changeTriggered on blur or Enter press(value: string) => 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

The Input component uses the following CSS variables for customization:

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)

Released under the MIT License.