|
1 | 1 | ---
|
2 |
| -title: React Checkbox Components |
3 |
| -name: Checkbox |
4 |
| -description: Create consistent cross-browser and cross-device checkboxes with our React checkbox components. |
| 2 | +title: React Bootstrap Checkbox Component |
| 3 | +name: Checkbox with Bootstrap Styling |
| 4 | +description: Learn how to build accessible and consistent Bootstrap-style checkboxes in React using CoreUI components. |
5 | 5 | route: /forms/checkbox/
|
6 |
| -other_frameworks: checkbox |
| 6 | +bootstrap_component: true |
7 | 7 | ---
|
8 | 8 |
|
9 |
| -## Approach |
| 9 | +## How to use React Bootstrap Checkbox component |
10 | 10 |
|
11 |
| -Browser default checkboxes and radios are replaced with the help of `<CFormCheck>`. Checkboxes are for selecting one or several options in a list. |
| 11 | +Use CoreUI’s `<CFormCheck>` to create cross-browser, accessible, and Bootstrap-styled checkboxes in React. Checkboxes are ideal for selecting one or more options from a list and can be styled, stacked, or grouped using layout utilities. |
12 | 12 |
|
13 |
| -## Checkboxes |
| 13 | +### Basic example |
14 | 14 |
|
15 |
| -<ExampleSnippet component="CheckboxExample" componentName="React Form Checkbox" /> |
| 15 | +Use the `<CFormCheck>` component to render a standard Bootstrap-style checkbox. |
16 | 16 |
|
17 |
| -### Indeterminate |
| 17 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxExample" componentName="React Bootstrap Checkbox" /> |
18 | 18 |
|
19 |
| -Checkboxes can utilize the `:indeterminate` pseudo-class when manually set via `indeterminate` property. |
| 19 | +### Indeterminate state |
20 | 20 |
|
21 |
| -<ExampleSnippet component="CheckboxIndeterminateExample" componentName="React Form Checkbox" /> |
| 21 | +Set the `indeterminate` property to render a checkbox in an indeterminate state, commonly used to indicate partial selections. |
22 | 22 |
|
23 |
| -### Disabled |
| 23 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxIndeterminateExample" componentName="React Bootstrap Checkbox" /> |
24 | 24 |
|
25 |
| -Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input's state. |
| 25 | +### Disabled state |
26 | 26 |
|
27 |
| -<ExampleSnippet component="CheckboxDisabledExample" componentName="React Form Checkbox" /> |
| 27 | +Add the `disabled` prop to disable a checkbox and automatically style its label in a muted color, following Bootstrap conventions. |
28 | 28 |
|
29 |
| -## Default (stacked) |
| 29 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxDisabledExample" componentName="React Bootstrap Checkbox" /> |
30 | 30 |
|
31 |
| -By default, any number of checkboxes that are immediate sibling will be vertically stacked and appropriately spaced. |
| 31 | +### Stacked layout (default) |
32 | 32 |
|
33 |
| -<ExampleSnippet component="CheckboxStackedExample" componentName="React Form Checkbox" /> |
| 33 | +By default, multiple checkboxes stack vertically and are spaced evenly. |
34 | 34 |
|
35 |
| -## Inline |
| 35 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxStackedExample" componentName="React Bootstrap Checkbox" /> |
36 | 36 |
|
37 |
| -Group checkboxes on the same horizontal row by adding `inline` boolean property to any `<CFormCheck>`. |
| 37 | +### Inline checkboxes |
38 | 38 |
|
39 |
| -<ExampleSnippet component="CheckboxInlineExample" componentName="React Form Checkbox" /> |
| 39 | +Use the `inline` boolean prop to place multiple checkboxes on the same horizontal row. |
40 | 40 |
|
41 |
| -## Reverse |
| 41 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxInlineExample" componentName="React Bootstrap Checkbox" /> |
42 | 42 |
|
43 |
| -Put your checkboxes on the opposite side by adding `reverse` boolean property. |
| 43 | +### Reversed checkboxes |
44 | 44 |
|
45 |
| -<ExampleSnippet component="CheckboxReverseExample" componentName="React Form Checkbox" /> |
| 45 | +Use the `reverse` prop to position the checkbox on the opposite side of the label. |
46 | 46 |
|
47 |
| -## Without labels |
| 47 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxReverseExample" componentName="React Bootstrap Checkbox" /> |
48 | 48 |
|
49 |
| -Remember to still provide some form of accessible name for assistive technologies (for instance, using `aria-label`). |
| 49 | +### Without labels |
50 | 50 |
|
51 |
| -<ExampleSnippet component="CheckboxWithoutLabelsExample" componentName="React Form Checkbox" /> |
| 51 | +If omitting a label, remember to include `aria-label` for accessibility compliance. |
| 52 | + |
| 53 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxWithoutLabelsExample" componentName="React Bootstrap Checkbox" /> |
52 | 54 |
|
53 | 55 | ## Checkbox toggle buttons
|
54 | 56 |
|
55 |
| -Create button-like checkboxes and radio buttons by using `button` boolean property on the `<CFormCheck>` component. These toggle buttons can further be grouped in a button group if needed. |
| 57 | +Transform checkboxes into Bootstrap-style toggle buttons using the `button` prop. You can also group them with button groups. |
56 | 58 |
|
57 |
| -<ExampleSnippet component="CheckboxToggleButtonsExample" componentName="React Form Checkbox" /> |
| 59 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxToggleButtonsExample" componentName="React Bootstrap Checkbox" /> |
58 | 60 |
|
59 |
| -### Outlined styles |
| 61 | +### Outlined toggle styles |
60 | 62 |
|
61 |
| -Different variants of button, such at the various outlined styles, are supported. |
| 63 | +Use outlined button variants for a lighter, bordered appearance. |
62 | 64 |
|
63 |
| -<ExampleSnippet component="CheckboxToggleButtonsOutlinedStylesExample" componentName="React Form Checkbox" /> |
| 65 | +<ExampleSnippet className="theme-bootstrap" component="CheckboxToggleButtonsOutlinedStylesExample" componentName="React Bootstrap Checkbox" /> |
64 | 66 |
|
65 |
| -## API |
| 67 | +## API reference |
66 | 68 |
|
67 |
| -Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here. |
| 69 | +Refer to the API documentation for detailed descriptions of all the available props and configuration options. |
68 | 70 |
|
69 | 71 | - [<CFormCheck />](../api/#cformcheck)
|
0 commit comments