Form
InputText
A single-line text box whose attributes land on the native input, with prefix and suffix content, a clear button and an optional mask.
WAI-ARIA tested
Import
main.ts
import { InputText } from '@vitral/vue';Basic
Typed: —
Masks
`mask` types into a pattern, as InputMask does, keeping the adornments and the clear button. It takes a pattern, a list, a function, or a mask object.
Value: —
Value: —
Value: —
Value: —
Sizes, variants and states
Fluid
API
Read from packages/vue/src/components/InputText/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| size | Size | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
| fluid | boolean | — |
| clearable | boolean | Shows a clear button while there is text. |
| type | string | — |
| mask | MaskProp | The pattern: `9` takes a digit, `a` a letter, `*` either; anything after `?` is optional; every other character is typed for the reader. A list of patterns lets the value take more than one shape: the first with room for what has been typed is shown, so `['999.999.999-99', '99.999.999/9999-99']` is a CPF that turns into a CNPJ at the twelfth digit, and back again when one is deleted. A function receives the characters typed so far, without literals, and returns the pattern to show. An object carries the pattern with its settings, so one mask can be defined once and passed to any field. |
| slotChar | string | What an empty slot shows: one character, or a string as long as the mask (`'mm/dd/yyyy'`). Defaults to `_`. |
| autoClear | boolean | Clear an unfinished value when the box loses focus. Defaults to true. |
| unmask | boolean | v-model receives only the typed characters, without the literals. |
| definitions | MaskDefinitions | Extra slot characters, each with the characters it accepts. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| clear | — | — |
| complete | event: { originalEvent: Event; value: string } | With a `mask`: every required slot is filled. |
Slots
| Name | Slot props | Description |
|---|---|---|
| prefix | — | Content inside the field, before the text: an icon, a currency sign. |
| suffix | — | Content inside the field, after the text: a unit, a button. |