Skip to content
On this page

Input

The inputs are a fundamental part of any project, with HopeKit you can add a input with a single line of code.

Basic Usage

The inputs have themes: default, transparent.

<template>
  <div class="grid grid-cols-2 gap-6 items-start">
    <HcInput
      v-model="value1"
      label="Default theme"
      placeholder="Enter something"
    />

    <HcInput
      v-model="value2"
      label="Transparent theme"
      placeholder="Enter something"
      theme="transparent"
    />
  </div>
</template>

<script lang="ts" setup>
import { HcInput } from '@deeepvision/hope-component-kit';
import { ref } from 'vue';

const value1 = ref('');
const value2 = ref('');
</script>

Sizes

The inputs have text sizes: small, medium. The inputs have sizes: small, medium.

<template>
  <div class="">
    <div class="grid grid-cols-2 gap-6 items-start">
      <HcInput
        v-model="value1"
        label="Medium text size"
        placeholder="Enter text..."
        text-size="medium"
      />

      <HcInput
        v-model="value2"
        label="Small text size"
        placeholder="Enter text..."
        text-size="small"
      />
    </div>

    <div class="mt-5">
      <HcInput
        v-model="value3"
        label="Medium size"
        placeholder="Enter text..."
        size="medium"
      />

      <HcInput
        v-model="value4"
        label="Small size"
        placeholder="Enter text..."
        size="small"
        class="mt-5"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { HcInput } from '@deeepvision/hope-component-kit';
import { ref } from 'vue';

const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
const value4 = ref('');
</script>

Disabled & readonly

Change the state of the button to disabled with the disabled property, the property is a boolean so you can add it without any value. Use boolean prop lock whether show lock icon when prop disabled is true.

Change the state of the button to readonly with the readonly property.

<template>
  <div class="grid grid-cols-2 gap-6 items-start">
    <HcInput
      v-model="value1"
      label="Disabled"
      placeholder="Enter text..."
      disabled
    />

    <HcInput
      v-model="value2"
      label="Disabled and lock"
      placeholder="Enter text..."
      disabled
      lock
    />

    <HcInput
      v-model="value3"
      label="Readonly"
      placeholder="Enter text..."
      readonly
    />
  </div>
</template>

<script lang="ts" setup>
import { HcInput } from '@deeepvision/hope-component-kit';
import { ref } from 'vue';

const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
</script>

Errors

Use props errorMsg to show error message or use prop boolean error to detarmitate error state of the component

This is an error message
<template>
  <div>
    <div class="grid grid-cols-2 gap-6 items-start">
      <HcInput
        v-model="value1"
        label="Error"
        placeholder="Enter text..."
        error
      />

      <HcInput
        v-model="value2"
        label="Error message"
        placeholder="Enter text..."
        error-msg="This is an error message"
      />
    </div>

    <div class="grid grid-cols-2 gap-6 items-start mt-5">
      <HcInput
        v-model="value3"
        label="Error and disabled"
        placeholder="Enter text..."
        error
        disabled
      />

      <HcInput
        v-model="value4"
        label="Error and readonly"
        placeholder="Enter text..."
        error
        readonly
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { HcInput } from '@deeepvision/hope-component-kit';
import { ref } from 'vue';

const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
const value4 = ref('');
</script>

States

There are different states: max-length, show-counter, success-icon, clearable, prefix-icon, suffix-icon, show-eye, maska.

<template>
  <div class="">
    <div class="grid grid-cols-2 gap-6 items-start">
      <HcInput
        v-model="value1"
        label="Max length"
        placeholder="Enter text..."
        :max-length="50"
      />

      <HcInput
        v-model="value2"
        label="Show success icon"
        placeholder="Enter text..."
        success-icon
      />
    </div>

    <div class="grid grid-cols-2 gap-6 items-start mt-5">
      <HcInput
        v-model="value3"
        label="Clearable"
        placeholder="Enter text..."
        clearable
      />

      <HcInput
        v-model="value4"
        label="Prefix Icon"
        placeholder="Enter text..."
        prefix-icon="search"
      />
    </div>

    <div class="grid grid-cols-2 gap-6 items-start mt-5">
      <HcInput
        v-model="value5"
        label="Show eye"
        placeholder="Enter text..."
        type="password"
        show-eye
      />

      <HcInput
        v-model="value6"
        label="Maska"
        placeholder="##:##:##"
        maska="##:##:##"
      />
    </div>
  </div>
</template>
<script lang="ts" setup>
import { HcInput } from '@deeepvision/hope-component-kit';
import { ref } from 'vue';

const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
const value4 = ref('');
const value5 = ref('');
const value6 = ref('');
</script>

Props

PropertyType Values Description Default
modelValueStringStringbinding valuefalse
labelStringStringlabel text
placeholderStringStringplaceholder text
maxLengthNumberNumbermax count of the symbolsundefined
showCounterBooleanBooleanshow symbols length countertrue
disabledBooleanBooleanwhether component is disabledfalse
readonlyBooleanBooleanwhether component is read onlyfalse
errorBooleanBooleandetermine if the component has error and change its style to that state.false
errorMsgStringStringerror message
successIconbooleantruefalsewhether show successIconfalse
clearablebooleantruefalsewhether show clearable buttonfalse
prefixIconStringStringprefix input iconfalse
showEyebooleantruefalsewhether show showEye iconfalse
sizeStringsmallmediumcomponent sizemedium
textSizeStringsmallmediumcomponent field text sizesmall
lockbooleantruefalsewhether show lock icon when disabledfalse
autoFocusbooleantruefalsesame as autofocus in native inputfalse
maska StringStringinput maskatext
themeStringdefaulttransparentcomponent themedefault
autocompleteBooleanBooleansame as autocomplete in native inputfalse
type Stringstringnumbernative 'type' attributetext
idStringStringnative 'id' attribute
nameStringStringnative 'name' attribute

Slots

PropertyType Values Description Default
prefix-customize prefix icon content
label-suffix-customize label suffix content
suffix-customize suffix icon content

Events

PropertyType Values Description Default
update:model-valueFunctionvalue - stringtriggers when the Input value change
keydown-enterFunctionevent - KeyboardEventtriggers when press enter
clearFunction-triggers when click on clear icon
focusFunctionevent - FocusEventtriggers when Input focuses
blurFunctionvalue - stringtriggers when Input blurs
inputFunctionvalue - stringtriggers when the Input value change

Created by DeepVision Software.