1 Star 0 Fork 0

LS/ls-design

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
zh-CN-react.md 3.54 KB
一键复制 编辑 原始数据 按行查看 历史

TextArea


简介

多行文本域,用于输入多行文本

安装使用

import { TextArea } from "@ls-design/ui-react";

基本使用

<TextArea />

指定行数

<TextArea rows="6" />

根据内容自动调整高度

<TextArea autosize />

字数统计

<TextArea showcount />

字数限制

<TextArea showcount maxlength="50" />

禁用状态

<TextArea disabled />

触发事件

export default () => {
  return (
    <TextArea
      onBlur={(event) => {
        Toast.text(`${event.target.value}, blur`);
      }}
      onInput={(event) => {
        Toast.text(`${event.target.value}, input`);
      }}
      onFocus={(event) => {
        Toast.text(`${event.target.value}, focus`);
      }}
      onCompositionStart={(event) => {
        Toast.text(`${event.target.value}, compositionStart`);
      }}
    />
  );
};

Props

参数 说明 类型 默认值
value 输入值 string
placeholder 提示文本 string
rows 行数 number 2
maxlength 最大字符数 number -
showcount 显示字数 boolean false
autocomplete 自动补全 boolean false
disabled 是否禁用 boolean false
readonly 是否只读 boolean false
id textarea 元素的 id,常用来配合 label 使用 string
onInput 文本域内容变化时触发 (e: { detail: { value: string } }) => void
onFocus 文本域获得焦点时触发 (e: { detail: { value: string } }) => void
onBlur 文本域失去焦点时触发 (e: { detail: { value: string } }) => void
onCompositionStart 输入法编辑器开始新的输入时触发 ()=> void

样式变量

组件提供了以下 CSS变量,可用于自定义样式

名称 说明 默认值
--textarea-color 文字颜色 #242729
--textarea-font-size 文字大小 14px
--textarea-text-align 文字位置 left
--textarea-text-count-align 统计字数位置 right
--textarea-count-color 统计字数颜色 #242729
--textarea-border-color 文本域边框颜色 #242729
--textarea-placeholder-color 占位文字颜色 #242729
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LShere/ls-design.git
git@gitee.com:LShere/ls-design.git
LShere
ls-design
ls-design
master

搜索帮助