Skip to content
On this page

TextField

TextField is a component that allows users to input text. There are two different types of text fields: Outlined Text Field and Filled Text Field. The usage of the two types is the same.

Props

NameTypeDefaultDescription
typeString'outlined'The type of the text field.
labelStringThe label of the text field.
placeholderStringThe placeholder of the text field.
iconString''The name of the icon shown in the text field.
iconTypeString''The type of the mty-icon.
trailingIconString''The name of the trailing icon shown in the text field.
supportingTextString''The supporting text shown in the text field.
disabledBoolfalseWhether the text field is disabled.
errorBoolfalseWhether the text field is in error state.
inputTextString''The input text.
prefixString''The prefix of the text field.
suffixString''The suffix of the text field.
validatorFunctionThe validator function.

type

ValueDescription
'outlined'Outlined text field.
'filled'Filled text field.

icon and iconType

Icon and iconType describe the icon shown in the text field. Look at the Mty Icons for more information.

validator

The validator function is used to validate the input text. It takes the input text as the argument and returns a boolean value. If the value is true, the input text is valid. Otherwise, the input text is invalid.

v-model

NameTypeDescription
inputTextString

Events

NameDescription
update:inputTextEmitted when the input text is changed.

Examples

The following example shows a outlined text field with the search round icon. The input variable is bound to the inputText prop as the model value. When you type in the text field, it will be updated.

vue
<text-field
  type="outlined"
  label="Search"
  icon="search"
  iconType="round"
  v-model:inputText="input"
/>

<script setup>
const input = ref('');
</script>