Preview Updated 2026-05-10

Textarea

Multi-line input — same color system as Input, with auto-resize, character count, and resize control.

Basic usage

Shares the same colors as Input. rows sets the initial row count; users can drag the bottom-right corner to resize.

<script setup lang="ts">
import { ref } from 'vue';
import { CfTextarea } from '@chufix-design/vue';

const note = ref('');
</script>

<template>
<CfTextarea v-model="note" placeholder="Say something…" :rows="3" />
</template>
import { useState } from 'react';
import { CfTextarea } from '@chufix-design/react';

export default function Demo() {
const [note, setNote] = useState('');
return (
  <CfTextarea
    value={note}
    onChange={(e) => setNote(e.target.value)}
    placeholder="Say something…"
    rows={3}
  />
);
}

Character count

maxlength enforces an upper bound (native limit). show-count displays the current character count in the bottom-right. Going over turns it red (though maxlength blocks input first).

0 / 50
<CfTextarea
v-model="bio"
placeholder="Bio (max 50 chars)"
:rows="3"
:maxlength="50"
show-count
/>
<CfTextarea
value={bio}
onChange={(e) => setBio(e.target.value)}
placeholder="Bio (max 50 chars)"
rows={3}
maxLength={50}
showCount
/>

Auto-resize

auto-resize makes the box grow with the content and hides the resize handle. Good when row count is unpredictable (comments, notes).

<CfTextarea
v-model="draft"
variant="filled"
auto-resize
placeholder="Auto-resizing textarea"
/>
<CfTextarea
value={draft}
onChange={(e) => setDraft(e.target.value)}
variant="filled"
autoResize
placeholder="Auto-resizing textarea"
/>

API

PropTypeDefaultDescription
variant'outline' | 'filled' | 'ghost''outline'Visual variant, matches Input
size'sm' | 'md' | 'lg''md'Font size / padding
rowsnumber3Initial row count
resize'none' | 'vertical' | 'horizontal' | 'both''vertical'User-resize behavior
autoResizebooleanfalseAuto-fit height to content (overrides resize)
errorbooleanfalseError border / focus ring
maxlengthnumberCharacter cap (maxLength in React)
showCountbooleanfalseShow character count in the bottom-right

反馈与讨论

Textarea · Discussion

0
0 / 600
一键发送
正在加载评论...