react-native-paper
Version:
Material design for React Native
49 lines (48 loc) • 1.63 kB
JavaScript
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { Platform } from 'react-native';
import CheckboxAndroid from './CheckboxAndroid';
import CheckboxIOS from './CheckboxIOS';
import { useInternalTheme } from '../../core/theming';
/**
* Checkboxes allow the selection of multiple options from a set.
*
* ## Usage
* ```js
* import * as React from 'react';
* import { Checkbox } from 'react-native-paper';
*
* const MyComponent = () => {
* const [checked, setChecked] = React.useState(false);
*
* return (
* <Checkbox
* status={checked ? 'checked' : 'unchecked'}
* onPress={() => {
* setChecked(!checked);
* }}
* />
* );
* };
*
* export default MyComponent;
* ```
*/
const Checkbox = _ref => {
let {
theme: themeOverrides,
...props
} = _ref;
const theme = useInternalTheme(themeOverrides);
return Platform.OS === 'ios' ? /*#__PURE__*/React.createElement(CheckboxIOS, _extends({}, props, {
theme: theme
})) : /*#__PURE__*/React.createElement(CheckboxAndroid, _extends({}, props, {
theme: theme
}));
};
export default Checkbox;
// @component-docs ignore-next-line
const CheckboxWithTheme = Checkbox;
// @component-docs ignore-next-line
export { CheckboxWithTheme as Checkbox };
//# sourceMappingURL=Checkbox.js.map