Textarea

采用皮肤外观的原生多行输入框:在最少与最多行数之间自动调整高度,支持无效状态,并带有会播报剩余字符数的字数统计。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 可用

用法

Grows from two to six rows. Shown on your public profile.

导入

ts
import {
  SoneTextareaCountComponent,
  SoneTextareaDirective,
} from "@surface-one/angular/textarea";

API 参考

SoneTextareaCountComponent组件

`<sone-textarea-count [for]="ta">` — the character counter of a `soneTextarea` (`#ta="soneTextarea"`): `12/200` against its `maxlength` (or the bare count), tinted as the limit nears. A polite live region says how many characters are left once few are, rather than on every keystroke.

选择器
sone-textarea-count
输入
名称类型 默认值
for必填

The textarea to count (`#ta="soneTextarea"`).

SoneTextareaDirective—
remainingLabel

"N characters left", read once few are left.

(remaining: number) => string(remaining) => remaining === 1 ? $localize`:A textarea counter, one character left:1 character left` : $localize`:A textarea counter, characters left:${remaining}:count: characters left`

SoneTextareaDirective指令

`textarea[soneTextarea]` — the native multi-line field (spartan/ui `hlmTextarea`, shadcn/ui Textarea) in the skin's `--textarea-*` look, which every `<textarea>` already has; the directive adds `autosize` (the height follows the content between `minRows` and `maxRows`), the `invalid` state and the character count a `sone-textarea-count` shows. Inside a `[soneField]` the field wires `aria-describedby` and `aria-invalid`.

选择器
textarea[soneTextarea]
导出为
soneTextarea
输入
名称类型 默认值
autosize

Grow and shrink with the content (the native resize handle goes away).

booleanfalse
minRows

The fewest rows an autosizing textarea shows.

number | nullnull
maxRows

The most rows it grows to; it scrolls past them.

number | nullnull
maxlength

The native `maxlength`; a `sone-textarea-count` counts against it.

number | nullnull
invalid

A failed check: `aria-invalid` and the destructive border and ring.

booleanfalse