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 edge 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.

Edge and States

The edge is a 1px inset ring that never changes size or content position; focus adds a 3px glow, an error turns it red, and disabled uses the disabled background.

Loading demo...

API Reference

Props

PropertyTypeDefaultDescription
modelValueThe input value, bound with v-model.
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.

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.
  • Inside a TxFormItem it takes the id, aria-describedby, aria-invalid and required, and draws a red border while the item shows an error; the form's disabled applies too. Attributes passed explicitly win.

Technologies

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