react-toolbox/components/checkbox
Vitaliy Filippov ba3993c811 Fix table styles, pass `style` to top-level element in inputs 2019-05-07 16:50:56 +03:00
..
Check.js Importing PropTypes from prop-types rather than react (#1413) 2017-04-17 16:14:17 +02:00
Checkbox.d.ts Restructure typescript definitions (#1114) 2017-01-18 08:37:37 +01:00
Checkbox.js Fix table styles, pass `style` to top-level element in inputs 2019-05-07 16:50:56 +03:00
config.css Make checkbox border color according to spec 2017-08-09 12:27:02 +02:00
index.d.ts Restructure typescript definitions (#1114) 2017-01-18 08:37:37 +01:00
index.js Update dependencies and linter (#1180) 2017-01-26 18:05:32 +01:00
readme.md fix: of -> or in documentation 2017-08-11 10:54:03 -04:00
theme.css Make checkbox border color according to spec 2017-08-09 12:27:02 +02:00

readme.md

Checkbox

Checkboxes allow the user to select multiple options from a set. If you have multiple options appearing in a list, you can preserve space by using checkboxes instead of on/off switches. If you have a single option, avoid using a checkbox and use an on/off switch instead.

import Checkbox from 'react-toolbox/lib/checkbox';

class TestCheckbox extends React.Component {
  state = { check1: true, check2: false };

  handleChange = (field, value) => {
    this.setState({...this.state, [field]: value});
  };

  render () {
    return (
      <div>
        <Checkbox
          checked={this.state.check1}
          label="Checked option"
          onChange={this.handleChange.bind(this, 'check1')}
        />
        <Checkbox
          checked={this.state.check2}
          label="Unchecked option"
          onChange={this.handleChange.bind(this, 'check2')}
        />
        <Checkbox
          checked
          disabled
          label="Disabled checkbox"
        />
      </div>
    );
  }
}

If you want to provide a theme via context, the component key is RTCheckbox.

Properties

Name Type Default Description
checked Boolean false Value for the checkbox, can be true or false.
children String, Element or Array Children to pass through the component.
className String '' Sets a class to give customized styles to the checkbox field.
disabled Boolean false If true, the checkbox shown as disabled and cannot be modified.
label String or node Text label to attach next to the checkbox element.
name String false The name of the field to set in the input checkbox.
onBlur Function Callback called when the checkbox is blurred.
onChange Function Callback called when the checkbox value is changed.
onFocus Function Callback called when the checkbox is focused

Theme

Name Description
check Used as root in the check element.
checked Used for the check element when it's checked.
disabled Used when the component is disabled.
field Used as the root class of the component.
input Used for the input element.
ripple Used for the ripple component.
text Used for the text label.