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

Checkbox

复选框

Basic Example

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

const { CheckboxItem } = Checkbox

export default () => {
    const [checked, onChange] = useState(true)
    const [itemChecked, onItemChange] = useState(true)
    return (
        <View style={styles.wrap}>
            <Text style={styles.boldTitle}>
                Checkbox
            </Text>
            <Text style={styles.title}>
                默认未点击
            </Text>
            <Checkbox style={styles.checkbox} />
            <Text style={styles.title}>
                勾选状态
            </Text>
            <Checkbox
                checked={checked}
                style={styles.checkbox}
                onChange={(e) => {
                    onChange(e.checked)
                }}
            />
            <Text style={styles.title}>
                选中不可点击状态
            </Text>
            <Checkbox style={styles.checkbox} checked disabled />
            <Text style={styles.title}>
                不可点击状态
            </Text>
            <Checkbox style={styles.checkbox} disabled />
            <Text style={styles.boldTitle}>
                CheckboxItem
            </Text>
            <CheckboxItem>
                选项1(默认未点击)
            </CheckboxItem>
            <CheckboxItem
                checked={itemChecked}
                onChange={(e) => {
                    onItemChange(e.checked)
                }}
            >
                选项2(勾选状态)
            </CheckboxItem>
            <CheckboxItem
                checked
                disabled
            >
                选项3(选中不可点状态)
            </CheckboxItem>
            <CheckboxItem
                disabled
                hideLine
            >
                选项3(不可点状态)
            </CheckboxItem>
        </View>
    )
}

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


Checkbox Props

属性说明类型默认值
defaultChecked是否默认选中Boolean无
checked当前是否选中Boolean无
disabled禁用Booleanfalse
onChangechange事件触发的回调函数(e: Object): void无

CheckboxItem Props

有 Checkbox 的所有 props 属性,另外还有

属性说明类型默认值
hideLine是否隐藏下面的线Booleanfalse
← RadioBadge →
  • Basic Example
  • Checkbox Props
  • CheckboxItem 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