MInput (.MINPUT)

A Vue custom Input type with validation and icons (or any child element).

Preview

Attributes

Nametypeoptionaldescription
v-model-falseto bind the input to a variable
idstringfalserequired for validating when using with MForm
patternRegExtrueuse it to validate the user input with a specific pattern (indicates that this input is required)
invalidMessagestringtruewrite a message for invalid input
validMessagestringtruewrite a message for valid input
autoDirectionbooleantrueadjusts the direction to rtl when writing in Arabic
typestringtruetext, password, date, number, email
borderedbooleantrueto get the bordered looking input
labelstringtrueto add a label to your input
transformer(string) => stringtrueto perform some transforming function on the text
shrinkedbooleantrueto shrink the input when it's not focused
unstyledbooleantrueto get the stock input look

Usage

The isValid() method returns a boolean value to tell if the curent input is valid according the pattern attribute.

The slot named "start" allows you to put an element at the start of the input.

The slot named "end" allows you to put an element at the end of the input.

<template>
  <MInput
    placeholder="username"
    autoDirection
    id="MInput"
    :pattern="/^[a-z]{1}\w{2,}$/"
    invalidMessage="Valid username should start with a letter and has a minimmum of 3 characters"
    validMessage="Nice username"
    v-model="username"
  >
    <template v-slot:start>
      <i class="fas fa-user"></i>
    </template>
    <template v-slot:end>
      <MButton icon-start="fas fa-angle-right" circled />
    </template>
  </MInput>
</template>