Skip to content

Input

A versatile input component with support for prefixes, suffixes, and clearable functionality.

Basic Usage

vue
<script setup>
import { ref } from 'vue'
const value = ref('')
</script>

<template>
  <MInput v-model="value" placeholder="Enter text..." />
</template>

Clearable

vue
<template>
  <MInput v-model="value" placeholder="Clearable input" clearable />
</template>

Disabled & Readonly

vue
<template>
  <MInput placeholder="Disabled" disabled />
  <MInput placeholder="Readonly" readonly />
</template>

Error State

vue
<template>
  <MInput v-model="value" placeholder="Error state" error />
</template>

With Prefix/Suffix Slots

vue
<template>
  <MInput v-model="value" placeholder="Search...">
    <template #prefix>
      <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
      </svg>
    </template>
  </MInput>
</template>

Props

NameTypeDefaultDescription
modelValuestring | number-Binding value (v-model)
typestring'text'Native input type
placeholderstring''Placeholder text
disabledbooleanfalseWhether the input is disabled
readonlybooleanfalseWhether the input is readonly
clearablebooleanfalseShow clear button
errorbooleanfalseError state styling

Events

NameParametersDescription
update:modelValue(value: string)Triggered when input value changes
focus(event: FocusEvent)Triggered when input receives focus
blur(event: FocusEvent)Triggered when input loses focus
enter(event: KeyboardEvent)Triggered when Enter key is pressed
clear-Triggered when clear button is clicked

Slots

NameDescription
prefixContent before the input
suffixContent after the input

Exposed Methods

NameParametersDescription
focus-Focus the input
blur-Blur the input

Released under the MIT License.