mCloud Design Mobile

mCloud Design Mobile

  • Docs
  • API
  • Help
  • Blog

›Component

Component

  • Button
  • SegmentedControl
  • SearchBar
  • Radio
  • Checkbox
  • Badge
  • Marquee
  • Switch
  • InputItem
  • NoticeBar
  • Textarea
  • List
  • Card
  • Picker
  • Label
  • EmptyView
  • Stepper
  • Tabs
  • DatePicker
  • Modal
  • Avatar
  • ActionSheet
  • ShareSheet

First Category

  • Button
  • Fifth Document

Textarea

多行文本输入

Basic Example

import React, { useState } from 'react'
import {
    View,
    Text,
    StyleSheet,
    ScrollView,
} from 'react-native'
import { Textarea } from 'mcloud-mobile'

export default () => {
    const [leftValue, onLeftChange] = useState('')
    const [topValue, onTopChange] = useState('')
    return (
        <View style={styles.wrap}>
            <ScrollView>
                <Text style={styles.boldTitle}>
                    Textarea
                </Text>
                <Text style={styles.title}>
                    标题在左
                </Text>
                <Textarea
                    label="标题"
                    autoHeight={true}
                    textAlign="right"
                    labelPosition="left"
                    placeholder="请输入标题"
                    value={leftValue}
                    onChange={(text) => {
                        onLeftChange(text)
                    }}
                />
                <Text style={styles.title}>
                    标题在上
                </Text>
                <Textarea
                    label="标题"
                    placeholder="请输入标题"
                    value={topValue}
                    onChange={(text) => {
                        onTopChange(text)
                    }}
                />
                <Text style={styles.title}>
                    规定行数
                </Text>
                <Textarea
                    label="标题"
                    rows={4}
                    placeholder="请输入标题"
                />
                <Text style={styles.title}>
                    高度自适应
                </Text>
                <Textarea
                    label="标题"
                    autoHeight={true}
                    placeholder="请输入标题"
                />
                <Text style={styles.title}>
                    多行计数
                </Text>
                <Textarea
                    label="标题"
                    rows={4}
                    count={80}
                    value="输入后文字显示很多很多很多很多很多很多很多很多输入后文字显示很多很多"
                    placeholder="请输入标题"
                />
                <Text style={styles.title}>
                    不可编辑
                </Text>
                <Textarea
                    label="标题"
                    value="输入后文字显示很多很多很多很多"
                    placeholder="请输入标题"
                    disabled={true}
                />
            </ScrollView>
        </View>
    )
}

const styles = StyleSheet.create({
    wrap: {
        flex: 1,
        backgroundColor: '#E6E6E6',
    },
    title: {
        fontSize: 14,
        color: '#1F2530',
        paddingVertical: 10,
        paddingLeft: 15,
    },
    boldTitle: {
        fontSize: 16,
        color: '#1F2530',
        paddingVertical: 10,
        paddingLeft: 10,
        fontWeight: '500',
    },
})

Props

属性说明类型默认值
valuevalue 值(受控与否参考https://facebook.github.io/react/docs/forms.html)String无
defaultValue设置初始默认值String-
placeholderplaceholderString''
placeholderTextColorplaceholderTextColorStringtheme.color_text_placeholder
editable是否可编辑booltrue
disabled是否禁用booltrue
autoFocus是否禁用booltrue
clear是否带清除功能(仅editable为true,disabled为false才生效)。在 Android 中, 处于编辑状态(focus)时 icon 才会出现, 且此组件被ScrollView包裹时, 设置ScrollView的keyboardShouldPersistTaps属性为handled或always时, icon才会正确响应点击事件boolfalse
count最大长度number无
textAlign输入框的位置,可选值有 left 和 rightstringright
onChangechange 事件触发的回调函数(val: string): void-
onBlurblur 事件触发的回调函数(val: string): void-
onFocusfocus 事件触发的回调函数(val: string): void-
labelNumber标签的文字个数,可用2-7之间的数字number5
last如果是最后一项,则将移除borderBottom(默认拥有borderBottom)boolfalse
rows显示几行number1
autoHeight高度自适应, autoHeight 和 rows 请二选一boolfalse
labeltitlestring无
labelPositiontitle 的位置 ,可选值有 top leftstringtop
onContentSizeChangecount变化的时候触发的方法(event: object): void无
← NoticeBarList →
  • Basic Example
  • Props
mCloud Design Mobile
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Your Name or Your Company Name