Input

A field that accepts single-line or multiline text.

VerifiedSince 0.3.4

Usage

Basic

Loading demo...

Search Row

Loading demo...

Input Types

type takes text, password, textarea, date, email, or number; rows sets the textarea height.

Loading demo...

Readonly and Disabled

Loading demo...

Clearable

clearable shows a focusable clear button while there is a value; it hides when disabled or readonly.

Loading demo...

Prefix and Suffix

The prefix / suffix slots take precedence over prefixIcon / suffixIcon.

Loading demo...

Best Practices

  • Show focus only through the subtle border and shadow shift; don't add a second focus ring around the wrapper unless the surrounding form requires one.
  • Keep search states light for toolbars and list filters; use TxSearchInput when Enter search or debounced remote search is part of the contract.
  • With type="number" the value is a number or ''; normalize it in your schema before persisting.
  • Give each field's icons one path: the slot or the icon prop.

API Reference

Props

PropertyTypeDefaultDescription
modelValue / v-modelThe input value.
placeholderPlaceholder text.
typeInput type; `textarea` renders a multiline field.
disabledDisables input.
readonlyMakes the field read-only.
clearableShows a clear button while there is a value.
rowsTextarea rows; `textarea` only.
prefixIconPrefix icon class; the `prefix` slot wins.
suffixIconSuffix icon class; the `suffix` slot wins.
capsLockTextText of the CapsLock warning on password fields, announced via `role="status"`.

Events

PropertyTypeDefaultDescription
update:modelValue-Fires when the value changes.
input-Fires on input, with the same value as `update:modelValue`.
focus-Fires when the native control gains focus.
blur-Fires when the native control loses focus.
clear-Fires after a clear.

Slots

PropertyTypeDefaultDescription
prefix--Prefix content, replacing `prefixIcon`.
suffix--Suffix content, replacing `suffixIcon`.

Exposed Methods

PropertyTypeDefaultDescription
focus-Focuses the native control.
blur-Blurs the native control.
clear-Clears the value; no-op when disabled or readonly.
setValue-Sets the value and emits `update:modelValue` and `input`.
getValue-Returns the current value.
inputEl-Ref to the native input or textarea.

Migration from FlatInput

FlatInput / TxFlatInput is retired; TxInput covers it:

FlatInputTxInput
areatype="textarea"
passwordtype="password"
icon="i-…"prefix-icon="i-…"
default slot (prefix content)#prefix slot
disabled / readonlydisabled / readonly
nonWindropped; the Windows-underline visual is gone

update:modelValue keeps its contract; focus / blur now come from the native input element.

Overview

  • type="number" emits Number(value) for non-empty input and '' when cleared.
  • Clearing emits update:modelValue, input, then clear; it is a no-op when disabled or readonly.
  • class / style stay on the wrapper; all other attrs go to the native input / textarea.

Technologies

  • index.ts exports both TuffInput and TxInput.
  • Source: packages/tuffex/packages/components/src/input/.
查看源码
packages/tuffex/packages/components/src/input/index.ts