UNPKG

1.25 kBMarkdownView Raw
1@# Checkbox
2
3A checkbox allows the user to toggle between checked, unchecked, and (rarely)
4indeterminate states.
5
6@reactExample CheckboxExample
7
8@## Props
9
10Use the `checked` prop instead of `value` in controlled mode to avoid typings
11issues. Enable the `indeterminate` prop for a third in-between state.
12
13```tsx
14// simple usage for string labels
15<Checkbox checked={this.state.isEnabled} label="Enabled" onChange={this.handleEnabledChange} />
16
17// advanced usage for JSX content
18<Checkbox checked={this.state.isEnabled} onChange={this.handleEnabledChange}>
19 <Icon icon="user" />
20 Gilad <strong>Gray</strong>
21</Checkbox>
22```
23
24This component supports the full range of HTML `<input>` props. The most common
25options are detailed below.
26
27@interface ICheckboxProps
28
29@## CSS
30
31Blueprint's custom checkboxes use an extra `.@ns-control-indicator` element
32after the `<input>` to achieve their custom styling. You should then wrap the
33whole thing in a `<label>` with the classes `.@ns-control.@ns-checkbox`.
34
35Note that attribute modifiers (`:checked`, `:disabled`) are applied on the
36internal `<input>` element. Further note that `:indeterminate` can only be set
37via JavaScript (the `Checkbox` React component supports it handily with a prop).
38
39@css checkbox