expo-radio-button is a beautiful and flexible radio button component
npm i expo-radio-button --save
yarn add expo-radio-button
import React, { useState } from "react";
import { Text, View } from "react-native";
import RadioButtonGroup, { RadioButtonItem } from "expo-radio-button";
export default function App() {
const [current, setCurrent] = useState("test");
return (
<View style={{ marginTop: 50 }}>
<RadioButtonGroup
containerStyle={{ marginBottom: 10 }}
selected={current}
onSelected={(value) => setCurrent(value)}
radioBackground="green"
>
<RadioButtonItem value="test2" label="Example with string" />
<RadioButtonItem
value="test"
label={
<Text style={{ color: "red" }}>Example passing React Element</Text>
}
/>
</RadioButtonGroup>
</View>
);
}
Property | Description |
---|---|
selected | Current value selected |
size | (integer) Radio button size |
containerStyle | Container Style |
radioStyle | Radio Button Style |
radioBackground | default blue |
Property | Description |
---|---|
onSelected | method called when pressed |
Property | Description |
---|---|
value | option value |
label | (string or JSX.element) |
style | View Style |
MIT
Free Software, Hell Yeah!