import * as React from "react"; import * as System from "~/components/system"; import * as Constants from "~/common/constants"; import Group from "~/components/system/Group"; import SystemPage from "~/components/system/SystemPage"; import ViewSourceLink from "~/components/system/ViewSourceLink"; import CodeBlock from "~/components/system/CodeBlock"; export default class SystemPageCheckboxes extends React.Component { state = { exampleOne: false, exampleTwo: true, }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; render() { return ( Checkboxes

The Checkbox component is used in forms when a users needs to select a true or false value.


Imports

Import React and the CheckBox Component.

{`import * as React from 'react'; import { CheckBox } from 'slate-react-system';`}

Usage

Declare the CheckBox component. Any children will be rendered as the label to the right of the checkbox.
{`class ExampleOne extends React.Component { state = { exampleOne: false } _handleChange = e => this.setState( { [e.target.name]: e.target.value } ); render() { return( Unchecked
This CheckBox default is unchecked.
) } } class ExampleTwo extends React.Component { state = { ExampleTwo: true } _handleChange = e => this.setState( { [e.target.name]: e.target.value } ); render() { return( Checked
This CheckBox default is checked.
) } }`}


Output

Unchecked
This CheckBox default is unchecked.


Checked
This CheckBox default is checked.



Accepted React Properties

onChange ), b: "function", c: "null", d: "Function called upon an onChange event", }, { id: 2, a: ( value ), b: "boolean", c: "false", d: "The value of the checkbox. Can be used to assign default values as well", }, { id: 3, a: "name", b: "string", c: "null", d: "Input name", }, ], }} />
); } }