Input
A field that accepts single-line or multiline text.
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
TxSearchInputwhen 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
| Property | Type | Default | Description |
|---|---|---|---|
| modelValue | The input value, bound with v-model. | ||
| placeholder | Placeholder text. | ||
| type | Input type; textarea renders a multiline field. | ||
| disabled | Disables input. | ||
| readonly | Makes the field read-only. | ||
| clearable | Shows a clear button while there is a value. | ||
| rows | Textarea rows; textarea only. | ||
| prefixIcon | Prefix icon class; the prefix slot wins. | ||
| suffixIcon | Suffix icon class; the suffix slot wins. | ||
| capsLockText | Text of the CapsLock warning on password fields, announced via role="status". |
Events
| Property | Type | Default | Description |
|---|---|---|---|
| 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
| Property | Type | Default | Description |
|---|---|---|---|
| prefix | - | - | Prefix content, replacing prefixIcon. |
| suffix | - | - | Suffix content, replacing suffixIcon. |
Exposed Methods
| Property | Type | Default | Description |
|---|---|---|---|
| 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"emitsNumber(value)for non-empty input and''when cleared.- Clearing emits
update:modelValue,input, thenclear; it is a no-op when disabled or readonly. class/stylestay on the wrapper; all other attrs go to the nativeinput/textarea.- Inside a
TxFormItemit takes the id,aria-describedby,aria-invalidandrequired, and draws a red border while the item shows an error; the form'sdisabledapplies too. Attributes passed explicitly win.
Technologies
index.tsexports bothTuffInputandTxInput.- Source:
packages/tuffex/packages/components/src/input/.
查看源码
packages/tuffex/packages/components/src/input/index.ts