|
| 1 | +Form groups support more complex form controls than simple [labels](#label), such as [control groups](#controlgroup). |
| 2 | + |
| 3 | +```js static |
| 4 | +import { FormGroup, Label } from 'blueprint-components'; |
| 5 | +``` |
| 6 | + |
| 7 | +Additionally: |
| 8 | + |
| 9 | +```js static |
| 10 | +import { Classes, InputGroup, Intent, Switch } from '@blueprintjs/core'; |
| 11 | +``` |
| 12 | + |
| 13 | +```jsx |
| 14 | +<FormGroup |
| 15 | + label={<Label text="Label A" />} |
| 16 | + helper="Helper text with details / user feedback" |
| 17 | + > |
| 18 | + <InputGroup |
| 19 | + leftIconName="calendar" |
| 20 | + /> |
| 21 | +</FormGroup> |
| 22 | +``` |
| 23 | + |
| 24 | +### Form Group Intent |
| 25 | + |
| 26 | +```html static |
| 27 | +<FormGroup intent={Intent.SUCCESS}> |
| 28 | + ... |
| 29 | +</FormGroup> |
| 30 | +``` |
| 31 | + |
| 32 | +```jsx |
| 33 | +<div> |
| 34 | + <FormGroup |
| 35 | + intent={Intent.SUCCESS} |
| 36 | + label={<Label text="Label A" />} |
| 37 | + helper="Intent only FormGroup component" |
| 38 | + > |
| 39 | + <InputGroup |
| 40 | + leftIconName="calendar" |
| 41 | + /> |
| 42 | + </FormGroup> |
| 43 | + <FormGroup |
| 44 | + intent={Intent.DANGER} |
| 45 | + label={<Label text="Label A" />} |
| 46 | + helper="Disabled with FormGroup and InputGroup components" |
| 47 | + > |
| 48 | + <InputGroup |
| 49 | + intent={Intent.DANGER} |
| 50 | + leftIconName="calendar" |
| 51 | + /> |
| 52 | + </FormGroup> |
| 53 | +</div> |
| 54 | +``` |
| 55 | + |
| 56 | +### Form Group Large |
| 57 | + |
| 58 | +To use larger form elements in `FormGroup`, add optional `large` prop: |
| 59 | + |
| 60 | +> Note: This prop will not increase in size it's children elements. You have to add `className={Classes.LARGE}` prop or `.pt-large` CSS class to these elements. Take a look at the source code of example below. |
| 61 | +
|
| 62 | +```html static |
| 63 | +<FormGroup large> |
| 64 | + ... |
| 65 | +</FormGroup> |
| 66 | +``` |
| 67 | + |
| 68 | +```jsx |
| 69 | +<div> |
| 70 | + <FormGroup |
| 71 | + large |
| 72 | + label={<Label text="Label A" />} |
| 73 | + helper="Helper text with details / user feedback" |
| 74 | + > |
| 75 | + <InputGroup |
| 76 | + className={Classes.LARGE} |
| 77 | + leftIconName="calendar" |
| 78 | + /> |
| 79 | + </FormGroup> |
| 80 | + <FormGroup |
| 81 | + className={Classes.LARGE} |
| 82 | + label={<Label text="Label A" />} |
| 83 | + helper="Note: Switch component does NOT work in this example." |
| 84 | + > |
| 85 | + <Switch className={Classes.LARGE} checked={false} label="Public" onChange={() => {}} /> |
| 86 | + </FormGroup> |
| 87 | +</div> |
| 88 | +``` |
| 89 | + |
| 90 | +### Form Group Inline |
| 91 | + |
| 92 | +To place form group elements on same line, add optional `inline` prop: |
| 93 | + |
| 94 | +```html static |
| 95 | +<FormGroup inline> |
| 96 | + ... |
| 97 | +</FormGroup> |
| 98 | +``` |
| 99 | + |
| 100 | +```jsx |
| 101 | +<div> |
| 102 | + <FormGroup |
| 103 | + inline |
| 104 | + label={<Label text="Label A" />} |
| 105 | + helper="Helper text with details / user feedback" |
| 106 | + > |
| 107 | + <InputGroup |
| 108 | + leftIconName="calendar" |
| 109 | + /> |
| 110 | + </FormGroup> |
| 111 | + <FormGroup |
| 112 | + inline |
| 113 | + label={<Label text="Label A" />} |
| 114 | + helper="Note: Switch component does NOT work in this example." |
| 115 | + > |
| 116 | + <Switch checked={false} label="Public" onChange={() => {}} /> |
| 117 | + </FormGroup> |
| 118 | +</div> |
| 119 | +``` |
| 120 | + |
| 121 | +### Form Group Disabled |
| 122 | + |
| 123 | +To make form group appear as disabled, add optional `disabled` prop: |
| 124 | + |
| 125 | +> Note: This prop will not add `disabled` as attribute to it's children elements. You have to add it manualy on form elments (`input`, `select`) and `.pt-disabled` CSS class to input groups. |
| 126 | +
|
| 127 | +```html static |
| 128 | +<FormGroup disabled> |
| 129 | + ... |
| 130 | +</FormGroup> |
| 131 | +``` |
| 132 | + |
| 133 | +```jsx |
| 134 | +<div> |
| 135 | + <FormGroup |
| 136 | + disabled |
| 137 | + label={<Label text="Label A" />} |
| 138 | + helper="Disabled only FormGroup component" |
| 139 | + > |
| 140 | + <InputGroup |
| 141 | + leftIconName="calendar" |
| 142 | + /> |
| 143 | + </FormGroup> |
| 144 | + <FormGroup |
| 145 | + disabled |
| 146 | + label={<Label disabled text="Label A" />} |
| 147 | + helper="Disabled with Label and InputGroup components" |
| 148 | + > |
| 149 | + <InputGroup |
| 150 | + disabled |
| 151 | + leftIconName="calendar" |
| 152 | + /> |
| 153 | + </FormGroup> |
| 154 | + <FormGroup |
| 155 | + disabled |
| 156 | + label={<Label text="Label A" />} |
| 157 | + helper="Disabled with FormGroup and Switch components" |
| 158 | + > |
| 159 | + <Switch disabled checked={false} label="Public" onChange={() => {}} /> |
| 160 | + </FormGroup> |
| 161 | +</div> |
| 162 | +``` |
0 commit comments