Skip to content

Input

Overview

This component provides a customizable input field with additional features like prepend/append icons, clearable input, custom label, error message display, and more. It can also be transformed into a select box with options if required.

Storybook

Props

Here are the properties that you can pass to the Input component:

PropertyTypeDefaultDescription
modelValueString, Number''The value of the input field.
typeString'text'Specifies the type of input (text, password, etc.).
nameString''Name attribute for the input.
errorBooleanfalseIf true, the input will be highlighted with an error state.
readonlyBooleanfalseRead-only mode for the input.
disabledBooleanfalseIf true, the input will be disabled.
size'sm', 'md', 'lg''md'Size of the input.
placeholderString''Placeholder text for the input.
prependIconString''Icon to prepend to the input.
appendIconString''Icon to append to the input.
colorString'default'Color scheme of the input.
shadowBooleanfalseIf true, the input will have a shadow.
labelString''Label text for the input.
idString''ID attribute for the input.
...ClassStringVarious defaultsClasses for various parts of the component.
...IconSizeIconSize'md'Size of various icons used in the component.
clearableBooleanfalseIf true, a clear icon will appear when there's input.
clearableIconString'ri:close-line'Icon used for the clear button.
roundedBooleanfalseRounded corners for the input.
hideErrorBooleanfalseIf true, error messages will be hidden.
hintString''Hint or help text for the input.
borderlessBooleanfalseIf true, the input will have no border.
noRingBooleanfalseIf true, the input won't have a focus ring.
errorMessageString''Custom error message to display.
asString'input'Determines if the component acts as an 'input' or 'select'.
optionsArray of Option[]Options for the select box (if as is set to 'select').

Events

EventPayloadDescription
update:modelValuevalue: string/numberEmitted when the input value changes.
clickPrependEmitted when the prepend area is clicked.
clickPrependIconEmitted when the prepend icon is clicked.
clickAppendEmitted when the append area is clicked.
clickAppendIconEmitted when the append icon is clicked.
clearEmitted when the input is cleared using the clearable button.

Slots

SlotDescription
defaultDefault slot for additional content.
labelCustom label content.
prependCustom content for the prepend section.
prepend.outerCustom content outside the prepend section.
appendCustom content for the append section.
append.outerCustom content outside the append section.
clearableCustom content for the clearable section.
hintCustom hint or help text.
errorCustom error message.

Methods

MethodDescription
focusFocuses the input component.

Usage

vue
<script setup lang="ts">
import {ref} from 'vue';
import {Input} from '@morpheme/forms';

const value = ref();
</script>

<template>
  <Input v-model="someValue" label="My Input" placeholder="Enter some value" />
</template>
<script setup lang="ts">
import {ref} from 'vue';
import {Input} from '@morpheme/forms';

const value = ref();
</script>

<template>
  <Input v-model="someValue" label="My Input" placeholder="Enter some value" />
</template>

This is a brief documentation for the Input component. For more advanced scenarios, you can check the component code to understand the full capabilities and functionalities it offers.