UNPKG

@cimpress/react-components

Version:
23 lines 1.3 kB
import React, { useState } from 'react'; import { Checkbox } from '@cimpress/react-components'; const initialState = { example: false, disable: false, indeterminate: false, }; const CheckboxDemo = () => { const [checkboxState, setCheckboxState] = useState(initialState); const onChange = (e, payload) => { const newState = Object.assign(Object.assign({}, checkboxState), { [payload]: !checkboxState[payload] }); setCheckboxState(newState); }; const { example, disable, indeterminate } = checkboxState; return (React.createElement("div", { className: "row" }, React.createElement("div", { className: "col-md-4" }, React.createElement("form", null, React.createElement(Checkbox, { label: "Example", checked: example, payload: "example", onChange: onChange, disabled: disable, indeterminate: indeterminate }), React.createElement(Checkbox, { label: "Disable the example", checked: disable, payload: "disable", onChange: onChange }), React.createElement(Checkbox, { label: React.createElement("b", null, "Make the example indeterminate"), checked: indeterminate, payload: "indeterminate", onChange: onChange }))))); }; export default CheckboxDemo; //# sourceMappingURL=checkbox.js.map