Textarea

A multi-line text field that grows with its content.

Install

If this is the first component in the project, set up once. This writes ermine.json and copies the theme stylesheet. The installation guide covers Vue, Nuxt and Astro.

npx ermineui init
pnpm dlx ermineui init
yarn dlx ermineui init
bunx ermineui init

Then add the component:

npx ermineui add textarea
pnpm dlx ermineui add textarea
yarn dlx ermineui add textarea
bunx ermineui add textarea

That copies 2 files into src/components/ui/textarea/. Files you already have are kept.

Use

import { Textarea } from '@/components/ui/textarea'
<script setup lang="ts">
import { Textarea } from '@/components/ui/textarea'
</script>

<template>
  <Textarea />
</template>

In Nuxt, with the auto-import setting, the tags work in templates without the import. In Astro, use it inside a Vue island. The props are documented in the source below, on each one.

What gets copied

FileWhere it goes
Textarea.vuesrc/components/ui/textarea/Textarea.vue
index.tssrc/components/ui/textarea/index.ts

The folders are the suggested ones. ermine.json says where yours are.

Source

This is exactly what the command copies. To install by hand, create each file below and the helpers listed above.

Textarea.vue 58 lines
<script setup lang="ts">
const model = defineModel<string>()
</script>

<template>
  <textarea v-model="model" class="er-textarea" />
</template>

<style>
@layer components {
  .er-textarea {
    display: block;
    width: 100%;
    min-height: 4.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--er-input);
    border-radius: var(--er-radius-md);
    background: var(--er-input-background);
    color: var(--er-foreground);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: var(--er-shadow-xs);
    resize: vertical;
    /* Grows with its content where the browser supports it. */
    field-sizing: content;
    transition:
      border-color var(--er-duration),
      outline-color var(--er-duration);
  }

  @media (min-width: 48rem) {
    .er-textarea {
      font-size: 0.875rem;
    }
  }

  .er-textarea::placeholder {
    color: var(--er-muted-foreground);
  }

  .er-textarea:focus-visible {
    border-color: var(--er-ring);
    outline: 2px solid color-mix(in oklab, var(--er-ring) 45%, transparent);
    outline-offset: 0;
  }

  .er-textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .er-textarea[aria-invalid='true'] {
    border-color: var(--er-destructive);
  }
}
</style>
index.ts 3 lines
/** Textarea — a multi-line text field that grows with its content. */
export { default as Textarea } from './Textarea.vue'