单选
Radio单选
单选按钮允许用户从一组选项中选择任何一个
语法
import React, { Component } from 'react';
import { Container, Header, Content, ListItem, Text, Radio, Right, Left } from 'native-base';
export default class RadioButtonExample extends Component {
render() {
return (
<Container>
<Header />
<Content>
<ListItem>
<Left>
<Text>Daily Stand Up</Text>
</Left>
<Right>
<Radio selected={false} />
</Right>
</ListItem>
<ListItem>
<Left>
<Text>Discussion with Client</Text>
</Left>
<Right>
<Radio selected={true} />
</Right>
</ListItem>
</Content>
</Container>
);
}
}
属性:
属性 | 默认值 | 选项 | 描述 |
---|---|---|---|
selected | false | boolean | Represents the state value of an item from set of choices. |
color | - | user-defined color | Inactive radio color |
selectedColor | - | user-defined color | Active radio color |
Custom Radio Button
语法
import React, { Component } from 'react';
import { Container, Header, Content, ListItem, Text, Radio, Right, Left } from 'native-base';
export default class CustomRadioButtonExample extends Component {
render() {
return (
<Container>
<Header />
<Content>
<ListItem selected={false} >
<Left>
<Text>Lunch Break</Text>
</Left>
<Right>
<Radio
color={"#f0ad4e"}
selectedColor={"#5cb85c"}
selected={false}
/>
</Right>
</ListItem>
<ListItem selected={true}>
<Left>
<Text>Discussion with Client</Text>
</Left>
<Right>
<Radio
color={"#f0ad4e"}
selectedColor={"#5cb85c"}
selected={true}
/>
</Right>
</ListItem>
</Content>
</Container>
);
}
}