Skip to content

Textarea

Neobrutalist-styled multi-line text input with variants, sizes, and v-model.

Demo

Preview

变体

尺寸

状态

v-model 绑定

值:

Installation

pnpm dlx brutx-vue@latest add textarea

Usage

vue
<script setup>
import { ref } from 'vue'
import { Textarea } from 'brutx-ui-vue'

const message = ref('')
</script>

<template>
    <Textarea v-model="message" placeholder="Type your message here..." />
</template>

With Label

vue
<script setup>
import { ref } from 'vue'
import { Textarea, Label } from 'brutx-ui-vue'

const bio = ref('')
</script>

<template>
    <div class="space-y-2">
        <Label for="bio">Bio</Label>
        <Textarea id="bio" v-model="bio" placeholder="Tell us about yourself..." />
    </div>
</template>

Disabled State

vue
<script setup>
import { Textarea } from 'brutx-ui-vue'
</script>

<template>
    <Textarea disabled placeholder="Disabled textarea" />
</template>

Readonly State

Set a readonly textarea via the readonly prop. In readonly state, the textarea is not editable but remains focusable for text selection. The cursor style is cursor-default, and opacity is not reduced (unlike disabled).

vue
<script setup>
import { ref } from 'vue'
import { Textarea } from 'brutx-ui-vue'

const content = ref('This is readonly content. Users can select and copy text but cannot modify it. Suitable for displaying agreement terms, history records, etc.')
</script>

<template>
    <Textarea v-model="content" readonly />
</template>

Variants

VariantDescription
defaultStandard border
errorDestructive border with primary focus shadow
successSuccess border with secondary focus shadow

Set different border styles via the variant prop:

vue
<template>
    <Textarea variant="default" placeholder="Default variant" />
    <Textarea variant="error" placeholder="Error variant" />
    <Textarea variant="success" placeholder="Success variant" />
</template>

Sizes

SizePaddingFont Size
smpx-3 py-2text-sm
defaultpx-4 py-3text-base
lgpx-5 py-4text-lg

Set different sizes via the size prop:

vue
<template>
    <Textarea size="sm" placeholder="Small size" />
    <Textarea size="default" placeholder="Default size" />
    <Textarea size="lg" placeholder="Large size" />
</template>

Props

PropTypeDefaultDescription
modelValuestringBinding value, supports v-model
variant'default' | 'error' | 'success''default'Border style variant
size'sm' | 'default' | 'lg''default'Size
disabledbooleanfalseWhether disabled
readonlybooleanfalseWhether readonly (not editable but selectable/copyable, cursor is cursor-default, opacity not reduced)
placeholderstringInternationalized fallback textPlaceholder text
errorMessagestringError message text, only displayed when variant="error", uses role="alert" for screen reader announcement
ariaLabelstringAccessibility label
ariaLabelledbystringAssociated label element ID
ariaDescribedbystringDescription element ID
ariaInvalidbooleanWhether marked as invalid
ariaRequiredbooleanWhether marked as required
classstringCustom CSS class

Events

EventPayloadDescription
update:modelValuestringTriggered when value changes

Exposed Methods (defineExpose)

Access the component instance via ref to call the following methods:

MethodDescription
focus()Focus the textarea
blur()Remove focus
select()Select all text in the textarea

Accessibility

  • ARIA attributes: Supports aria-label, aria-labelledby, aria-describedby, aria-invalid, aria-required attributes for assistive technologies (e.g. screen readers)
vue
<script setup>
import { ref } from 'vue'
import { Textarea } from 'brutx-ui-vue'

const bio = ref('')
</script>

<template>
    <Textarea
        v-model="bio"
        aria-label="Bio"
        aria-required="true"
        aria-invalid="false"
        placeholder="Enter your bio..."
    />
</template>

Customization

Textarea defaults to resize-none. To allow resizing, override with a custom class:

vue
<script setup>
import { Textarea } from 'brutx-ui-vue'
</script>

<template>
    <Textarea class="resize-y" placeholder="Resizable textarea" />
</template>

Brute force builds.