Skip to content

Input

A simple vue input component.

Demo ​

Default

Disabled

Read-only

With Help Text

Help Text

Label Hidden

Compact

Validation States

Looks good!
Are you sure about this?
This field is required.

Required

Media Input — Start & End

https://
$USD

Input Types

Install ​

bash
npm i @vuesimple/vs-input

Usage ​

html
<template>
  <vs-input v-model="name" label="Name" placeholder="Enter your name"></vs-input>
</template>

<script>
  import VsInput from '@vuesimple/vs-input';

  export default {
    components: {
      VsInput,
    },
    data() {
      return {
        name: '',
      };
    },
  };
</script>

CDN ​

html
<script src="https://cdn.jsdelivr.net/npm/@vuesimple/vs-input@3.1.7/dist/index.min.js"></script>
javascript
// Main/Entry file
app.use(VsInput.plugin);
html
<template>
  <vs-input v-model="name" label="Name" placeholder="Enter your name"></vs-input>
</template>

Props ​

NameTypeDefaultDescription
modelValueAny''The input value (supports v-model)
typeStringtextHTML input type. (text, email, password, number, search, url, tel)
labelString-Label displayed above the input
hideLabelBooleanfalseVisually hides the label while keeping it accessible to screen readers
hintString-Helper text shown below the label
placeholderString''Placeholder text inside the input
disabledBooleanfalseDisables the input
readOnlyBooleanfalseMakes the input read-only
requiredBooleanfalseMarks the field as required (shows * next to label)
isCompactBooleanfalseCompact styling with reduced padding
isBareBooleanfalseRemoves border and background
maxlengthNumber-Maximum number of characters allowed
validationString-Validation state. (success, warning, error)
messageString-Message text shown below the input (paired with validation)

Events ​

NameDescription
update:modelValueEmitted on every keystroke (v-model)
changeEmitted when the input value is committed
focusEmitted when the input gains focus
blurEmitted when the input loses focus

Slots ​

NameDescription
startContent placed before the input (e.g. icon, prefix text)
endContent placed after the input (e.g. icon, suffix text)

Examples ​

Basic Input ​

html
<vs-input v-model="name" label="Name" placeholder="Enter your name"></vs-input>

With Hint Text ​

html
<vs-input v-model="email" label="Email" hint="We'll never share your email." placeholder="you@example.com"></vs-input>

Required Field ​

html
<vs-input v-model="email" label="Email address" type="email" placeholder="you@example.com" required></vs-input>

Disabled ​

html
<vs-input v-model="name" label="Name" disabled></vs-input>

Read-only ​

html
<vs-input v-model="name" label="Name" read-only></vs-input>

Compact ​

html
<vs-input v-model="name" label="Name" is-compact></vs-input>

Bare (no border) ​

html
<vs-input v-model="name" label="Name" is-bare></vs-input>

Hidden Label ​

html
<vs-input v-model="query" label="Search" hide-label placeholder="Search…"> </vs-input>

Validation States ​

html
<vs-input v-model="email" label="Email" validation="success" message="Looks good!"></vs-input>
<vs-input v-model="email" label="Email" validation="warning" message="Are you sure about this?"></vs-input>
<vs-input v-model="email" label="Email" validation="error" message="This field is required."></vs-input>

Media Input — Start Icon ​

html
<vs-input v-model="query" label="Search" placeholder="Search…">
  <template #start>
    <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">
      <path
        d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z"
      />
    </svg>
  </template>
</vs-input>

Media Input — Start & End Addons ​

html
<vs-input v-model="price" label="Price" placeholder="0.00" type="number">
  <template #start>$</template>
  <template #end>USD</template>
</vs-input>

URL Prefix ​

html
<vs-input v-model="url" label="Website" placeholder="example.com" type="url">
  <template #start>
    <span>https://</span>
  </template>
</vs-input>

Events Handling ​

html
<template>
  <vs-input
    v-model="email"
    label="Email"
    type="email"
    @change="handleChange"
    @focus="handleFocus"
    @blur="handleBlur"
  ></vs-input>
</template>

<script>
  export default {
    data() {
      return {
        email: '',
      };
    },

    methods: {
      handleChange(value) {
        console.log('Value committed:', value);
      },

      handleFocus(event) {
        console.log('Input focused');
      },

      handleBlur(event) {
        console.log('Input blurred');
      },
    },
  };
</script>