Skip to content
On this page

Textarea

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

Basic Usage

The textarea have themes: default, transparent.

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

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

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

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

Sizes

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

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

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

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

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

<script lang="ts" setup>
import { HcTextarea } 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>
  <ClientOnly>
    <div class="grid grid-cols-2 gap-6 items-start">
      <HcTextarea
        v-model="value1"
        label="Disabled"
        placeholder="Enter text..."
        disabled
      />

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

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

<script lang="ts" setup>
import { HcTextarea } 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

<template>
  <ClientOnly>
    <div>
      <div class="grid grid-cols-2 gap-6 items-start">
        <HcTextarea
          v-model="value1"
          label="Error"
          placeholder="Enter text..."
          error
        />

        <HcTextarea
          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">
        <HcTextarea
          v-model="value3"
          label="Error and disabled"
          placeholder="Enter text..."
          error
          disabled
        />

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

<script lang="ts" setup>
import { HcTextarea } 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, new-line-ctrl-enter, hide-scroll, line-break.

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

        <HcTextarea
          v-model="value2"
          label="Hide scroll"
          placeholder="Enter text..."
          hide-scroll
        />
      </div>

      <div class="grid grid-cols-2 gap-6 items-start mt-5">
        <HcTextarea
          v-model="value3"
          label="Deny line break"
          placeholder="Enter text..."
          :line-break="false"
        />

        <HcTextarea
          v-model="value4"
          label="New line only with Ctrl + Enter"
          placeholder="Enter text..."
          new-line-ctrl-enter
        />
      </div>
    </div>
  </ClientOnly>
</template>
<script lang="ts" setup>
import { HcTextarea } from '@deeepvision/hope-component-kit';
import { ref } from 'vue';

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

Props

PropertyType Values Description Default
modelValueStringStringbinding valuefalse
idStringStringnative 'id' attribute
labelStringStringlabel text
placeholderStringStringplaceholder text
rowsNumberNumbercount of the rows3
maxLengthNumberNumbermax count of the symbolsundefined
errorBooleanBooleandetermine if the component has error and change its style to that state.false
errorMsgStringStringerror message
disabledBooleanBooleanwhether component is disabledfalse
lockbooleantruefalsewhether show lock icon when disabledfalse
readonlyBooleanBooleanwhether component is read onlyfalse
sizeStringsmallmediumcomponent sizemedium
textSizeStringsmallmediumcomponent field text sizesmall
autosizeBooleanBooleanwhether textarea has an adaptive heighttrue
lineBreakbooleantruefalseallow line breaktrue
newLineCtrlEnterbooleantruefalsewhether allow can make new line only with keys Ctrl + Enterfalse
autofocusbooleantruefalsesame as autofocus in native textareafalse
themeStringdefaulttransparenttheme of the componentdefault
hideScrollbooleantruefalsehide scroll in textarea componentfalse

Slots

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

Events

PropertyType Values Description Default
update:model-valueFunctionvalue - stringtriggers when the Textarea value change
keydown-enterFunctionevent - KeyboardEventtriggers when press enter
focusFunctionevent - FocusEventtriggers when Textarea focuses
blurFunctionvalue - stringtriggers when Textarea blurs
inputFunctionvalue - stringtriggers when the Textarea value change

Created by DeepVision Software.