react-native-paper
Version:
Material design for React Native
70 lines (66 loc) • 2.02 kB
JavaScript
import * as React from 'react';
import { Platform } from 'react-native';
import RadioButtonAndroid from './RadioButtonAndroid';
import RadioButtonIOS from './RadioButtonIOS';
import { withTheme } from '../../core/theming';
/**
* Radio buttons allow the selection a single option from a set.
*
* <div class="screenshots">
* <figure>
* <img src="screenshots/radio-enabled.android.png" />
* <figcaption>Android (enabled)</figcaption>
* </figure>
* <figure>
* <img src="screenshots/radio-disabled.android.png" />
* <figcaption>Android (disabled)</figcaption>
* </figure>
* <figure>
* <img src="screenshots/radio-enabled.ios.png" />
* <figcaption>iOS (enabled)</figcaption>
* </figure>
* <figure>
* <img src="screenshots/radio-disabled.ios.png" />
* <figcaption>iOS (disabled)</figcaption>
* </figure>
* </div>
*
* ## Usage
* ```js
* import * as React from 'react';
* import { View } from 'react-native';
* import { RadioButton } from 'react-native-paper';
*
* const MyComponent = () => {
* const [checked, setChecked] = React.useState('first');
*
* return (
* <View>
* <RadioButton
* value="first"
* status={ checked === 'first' ? 'checked' : 'unchecked' }
* onPress={() => setChecked('first')}
* />
* <RadioButton
* value="second"
* status={ checked === 'second' ? 'checked' : 'unchecked' }
* onPress={() => setChecked('second')}
* />
* </View>
* );
* };
*
* export default MyComponent;
* ```
*/
const RadioButton = props => {
const Button = Platform.select({
default: RadioButtonAndroid,
ios: RadioButtonIOS
});
return /*#__PURE__*/React.createElement(Button, props);
};
export default withTheme(RadioButton); // @component-docs ignore-next-line
const RadioButtonWithTheme = withTheme(RadioButton); // @component-docs ignore-next-line
export { RadioButtonWithTheme as RadioButton };
//# sourceMappingURL=RadioButton.js.map