Skip to content

Textarea 文本域

显示表单文本域或看起来像文本域的组件。

基础用法

Value:

Example

自动高度

根据内容自动调整高度。

Example

禁用状态

Example

带标签

Your message will be copied to the support team.

Example

带字符计数

84 / 100
Example

可清除

Example

错误状态

Please enter a valid message.

Example

尺寸

Example

调整大小行为

你可以使用 resize 属性控制调整大小的行为。

Example

主题定制

你可以使用 Tailwind CSS 类自定义文本域的外观,或者通过覆盖全局 CSS 变量。

全局主题配置

BrTextarea 组件遵循 BrConfigProvider 提供的主题配置。

vue
<script setup>
import { BrConfigProvider, BrTextarea } from '@breezeui/vue'

const theme = {
  primary: '#10b981', // Emerald 500
  radius: 0.75, // 0.75rem
}
</script>

<template>
  <BrConfigProvider :theme="theme">
    <BrTextarea placeholder="Themed Textarea" />
  </BrConfigProvider>
</template>

Tailwind 定制

你也可以使用 class 属性添加自定义样式:

vue
<BrTextarea class="border-purple-500 focus-visible:ring-purple-500 min-h-[150px]" />

API

Props

属性名类型默认值说明
modelValuestring | number-文本域的值。
defaultValuestring | number-文本域的默认值。
disabledbooleanfalse是否禁用文本域。
readonlybooleanfalse是否只读。
placeholderstring-占位文本。
sizedefault | xs | sm | md | lg | xl | 2xldefault文本域尺寸。
errorbooleanfalse是否显示错误状态。
clearablebooleanfalse是否显示清除按钮。
autoSizeboolean | objectfalse是否自动调整高度。
rowsnumber | string3可见行数。
maxlengthnumber | string-允许的最大字符数。
showCountbooleanfalse是否显示字符计数(需要 maxlength)。
resizenone | vertical | horizontal | bothvertical调整大小的行为。

Events

名称参数说明
update:modelValuestring | number当文本域值变化时触发。
clear-当点击清除按钮时触发。
inputEvent当文本域值变化时触发。
changeEvent当文本域值变化时触发(blur)。
focusEvent当文本域获得焦点时触发。
blurEvent当文本域失去焦点时触发。