Radio

版本要求:
@ray-js/ray≥0.5.10

描述

单选框,用于在一组互斥选项中选中其中一项。

属性

属性类型必填默认值说明
valuestring否-radio 标识;该 radio 选中时,radio-group 的 change 事件会携带其 value
checkedboolean否false当前是否选中,可作默认选中
disabledboolean否false是否禁用
colorstring否#007AFFradio 的颜色,同 CSS 的 color

示例代码

基础用法

import React from 'react';
import { Radio, View } from '@ray-js/ray';

export default function () {
  return (
    <View style={{ padding: '20px' }}>
      <Radio checked />
    </View>
  );
}

不同状态

import React from 'react';
import { Radio, View, Text } from '@ray-js/ray';

export default function () {
  return (
    <View style={{ padding: '20px' }}>
      <View style={{ marginBottom: '10px' }}>
        <Text>默认状态:</Text>
        <Radio />
      </View>
      <View style={{ marginBottom: '10px' }}>
        <Text>选中状态:</Text>
        <Radio checked />
      </View>
      <View style={{ marginBottom: '10px' }}>
        <Text>禁用状态:</Text>
        <Radio disabled />
      </View>
      <View style={{ marginBottom: '10px' }}>
        <Text>自定义颜色:</Text>
        <Radio color="#ff0000" checked />
      </View>
    </View>
  );
}