| 1 |
--- |
| 2 |
id: Input group |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-input-group |
| 5 |
---### Overview |
| 6 |
|
| 7 |
Use the input group to extend form controls by adding text, buttons, selects, etc. The input group handles border overlap. |
| 8 |
|
| 9 |
## Examples |
| 10 |
|
| 11 |
### Variations |
| 12 |
|
| 13 |
```html |
| 14 |
<div class="pf-v6-c-input-group"> |
| 15 |
<div class="pf-v6-c-input-group__item"> |
| 16 |
<button |
| 17 |
class="pf-v6-c-button pf-m-control" |
| 18 |
type="button" |
| 19 |
id="textAreaButton1" |
| 20 |
> |
| 21 |
<span class="pf-v6-c-button__text">Button</span> |
| 22 |
</button> |
| 23 |
</div> |
| 24 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 25 |
<span class="pf-v6-c-form-control pf-m-textarea pf-m-resize-both"> |
| 26 |
<textarea |
| 27 |
name="textarea1" |
| 28 |
id="textarea1" |
| 29 |
aria-label="Textarea with buttons" |
| 30 |
aria-describedby="textAreaButton1" |
| 31 |
></textarea> |
| 32 |
</span> |
| 33 |
</div> |
| 34 |
<div class="pf-v6-c-input-group__item"> |
| 35 |
<button class="pf-v6-c-button pf-m-control" type="button"> |
| 36 |
<span class="pf-v6-c-button__text">Button</span> |
| 37 |
</button> |
| 38 |
</div> |
| 39 |
</div> |
| 40 |
<br /> |
| 41 |
<div class="pf-v6-c-input-group"> |
| 42 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 43 |
<span class="pf-v6-c-form-control pf-m-textarea pf-m-resize-both"> |
| 44 |
<textarea |
| 45 |
name="textarea2" |
| 46 |
id="textarea2" |
| 47 |
aria-label="Textarea with button" |
| 48 |
aria-describedby="textAreaButton2" |
| 49 |
></textarea> |
| 50 |
</span> |
| 51 |
</div> |
| 52 |
<div class="pf-v6-c-input-group__item"> |
| 53 |
<button |
| 54 |
class="pf-v6-c-button pf-m-control" |
| 55 |
type="button" |
| 56 |
id="textAreaButton2" |
| 57 |
> |
| 58 |
<span class="pf-v6-c-button__text">Button</span> |
| 59 |
</button> |
| 60 |
</div> |
| 61 |
</div> |
| 62 |
<br /> |
| 63 |
<div class="pf-v6-c-input-group"> |
| 64 |
<div class="pf-v6-c-input-group__item"> |
| 65 |
<button |
| 66 |
class="pf-v6-c-button pf-m-control" |
| 67 |
type="button" |
| 68 |
id="textAreaButton3" |
| 69 |
> |
| 70 |
<span class="pf-v6-c-button__text">Button</span> |
| 71 |
</button> |
| 72 |
</div> |
| 73 |
<div class="pf-v6-c-input-group__item"> |
| 74 |
<button class="pf-v6-c-button pf-m-control" type="button"> |
| 75 |
<span class="pf-v6-c-button__text">Button</span> |
| 76 |
</button> |
| 77 |
</div> |
| 78 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 79 |
<span class="pf-v6-c-form-control pf-m-textarea pf-m-resize-both"> |
| 80 |
<textarea |
| 81 |
name="textarea3" |
| 82 |
id="textarea3" |
| 83 |
aria-label="Textarea with buttons" |
| 84 |
aria-describedby="textAreaButton3" |
| 85 |
></textarea> |
| 86 |
</span> |
| 87 |
</div> |
| 88 |
<div class="pf-v6-c-input-group__item"> |
| 89 |
<button class="pf-v6-c-button pf-m-control" type="button"> |
| 90 |
<span class="pf-v6-c-button__text">Button</span> |
| 91 |
</button> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
<br /> |
| 95 |
<div class="pf-v6-c-input-group"> |
| 96 |
<div class="pf-v6-c-input-group__item"> |
| 97 |
<button |
| 98 |
class="pf-v6-c-menu-toggle pf-m-form" |
| 99 |
type="button" |
| 100 |
aria-expanded="false" |
| 101 |
id="select-example-collapsed1" |
| 102 |
> |
| 103 |
<span class="pf-v6-c-menu-toggle__text">Select</span> |
| 104 |
<span class="pf-v6-c-menu-toggle__controls"> |
| 105 |
<span class="pf-v6-c-menu-toggle__toggle-icon"> |
| 106 |
<svg |
| 107 |
class="pf-v6-svg" |
| 108 |
fill="currentColor" |
| 109 |
viewBox="0 0 20 20" |
| 110 |
aria-hidden="true" |
| 111 |
role="img" |
| 112 |
width="1em" |
| 113 |
height="1em" |
| 114 |
> |
| 115 |
<path |
| 116 |
d="m17.65 8.76-6.674 5.72a1.496 1.496 0 0 1-.976.365c-.347 0-.694-.122-.978-.366l-6.673-5.72A1 1 0 0 1 3 7h14a1 1 0 0 1 .65 1.76Z" |
| 117 |
/> |
| 118 |
</svg> |
| 119 |
</span> |
| 120 |
</span> |
| 121 |
</button> |
| 122 |
</div> |
| 123 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 124 |
<span class="pf-v6-c-form-control"> |
| 125 |
<input |
| 126 |
type="text" |
| 127 |
id="textInput4" |
| 128 |
name="textInput4" |
| 129 |
aria-label="Input with select and button" |
| 130 |
aria-describedby="inputSelectButton1" |
| 131 |
/> |
| 132 |
</span> |
| 133 |
</div> |
| 134 |
<div class="pf-v6-c-input-group__item"> |
| 135 |
<button |
| 136 |
class="pf-v6-c-button pf-m-control" |
| 137 |
type="button" |
| 138 |
id="inputSelectButton1" |
| 139 |
> |
| 140 |
<span class="pf-v6-c-button__text">Button</span> |
| 141 |
</button> |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
<br /> |
| 145 |
<div class="pf-v6-c-input-group"> |
| 146 |
<div class="pf-v6-c-input-group__item pf-m-box"> |
| 147 |
<span class="pf-v6-c-input-group__text"> |
| 148 |
<i class="fas fa-dollar-sign" aria-hidden="true"></i> |
| 149 |
</span> |
| 150 |
</div> |
| 151 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 152 |
<span class="pf-v6-c-form-control"> |
| 153 |
<input |
| 154 |
type="number" |
| 155 |
id="textInput5" |
| 156 |
name="textInput5" |
| 157 |
aria-label=" Dollar amount input example" |
| 158 |
/> |
| 159 |
</span> |
| 160 |
</div> |
| 161 |
<div class="pf-v6-c-input-group__item pf-m-box"> |
| 162 |
<span class="pf-v6-c-input-group__text">.00</span> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
<br /> |
| 166 |
<div class="pf-v6-c-input-group"> |
| 167 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 168 |
<span class="pf-v6-c-form-control"> |
| 169 |
<input |
| 170 |
type="email" |
| 171 |
id="textInput6" |
| 172 |
name="textInput6" |
| 173 |
aria-label="Email input field" |
| 174 |
aria-describedby="email-example" |
| 175 |
/> |
| 176 |
</span> |
| 177 |
</div> |
| 178 |
<div class="pf-v6-c-input-group__item pf-m-box"> |
| 179 |
<span class="pf-v6-c-input-group__text" id="email-example">@example.com</span> |
| 180 |
</div> |
| 181 |
</div> |
| 182 |
<br /> |
| 183 |
<div class="pf-v6-c-input-group"> |
| 184 |
<div class="pf-v6-c-input-group__item pf-m-box"> |
| 185 |
<span class="pf-v6-c-input-group__text"> |
| 186 |
<i class="fas fa-at" aria-hidden="true"></i> |
| 187 |
</span> |
| 188 |
</div> |
| 189 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 190 |
<span class="pf-v6-c-form-control pf-m-required pf-m-error"> |
| 191 |
<input |
| 192 |
required |
| 193 |
type="email" |
| 194 |
id="textInput7" |
| 195 |
name="textInput7" |
| 196 |
aria-invalid="true" |
| 197 |
aria-label="Error state username example" |
| 198 |
/> |
| 199 |
<span class="pf-v6-c-form-control__utilities"> |
| 200 |
<span class="pf-v6-c-form-control__icon pf-m-status"> |
| 201 |
<i class="fas fa-exclamation-circle" aria-hidden="true"></i> |
| 202 |
</span> |
| 203 |
</span> |
| 204 |
</span> |
| 205 |
</div> |
| 206 |
</div> |
| 207 |
<br /> |
| 208 |
<div class="pf-v6-c-input-group"> |
| 209 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 210 |
<span class="pf-v6-c-form-control"> |
| 211 |
<input |
| 212 |
type="text" |
| 213 |
id="textInput13" |
| 214 |
name="textInput13" |
| 215 |
aria-label="Input example with popover" |
| 216 |
/> |
| 217 |
</span> |
| 218 |
</div> |
| 219 |
<div class="pf-v6-c-input-group__item"> |
| 220 |
<button |
| 221 |
class="pf-v6-c-button pf-m-control" |
| 222 |
type="button" |
| 223 |
aria-label="Popover for input" |
| 224 |
> |
| 225 |
<span class="pf-v6-c-button__icon"> |
| 226 |
<svg |
| 227 |
class="pf-v6-svg" |
| 228 |
fill="currentColor" |
| 229 |
viewBox="0 0 512 512" |
| 230 |
aria-hidden="true" |
| 231 |
role="img" |
| 232 |
width="1em" |
| 233 |
height="1em" |
| 234 |
> |
| 235 |
<path |
| 236 |
d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z" |
| 237 |
/> |
| 238 |
</svg> |
| 239 |
</span> |
| 240 |
</button> |
| 241 |
</div> |
| 242 |
</div> |
| 243 |
<br /> |
| 244 |
<div class="pf-v6-c-input-group"> |
| 245 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 246 |
<span class="pf-v6-c-form-control"> |
| 247 |
<input |
| 248 |
type="text" |
| 249 |
id="textInput12" |
| 250 |
name="textInput12" |
| 251 |
aria-label="Input example with popover" |
| 252 |
/> |
| 253 |
</span> |
| 254 |
</div> |
| 255 |
<div class="pf-v6-c-input-group__item pf-m-plain"> |
| 256 |
<button |
| 257 |
class="pf-v6-c-button pf-m-plain" |
| 258 |
type="button" |
| 259 |
aria-label="Popover for input" |
| 260 |
> |
| 261 |
<span class="pf-v6-c-button__icon"> |
| 262 |
<svg |
| 263 |
class="pf-v6-svg" |
| 264 |
fill="currentColor" |
| 265 |
viewBox="0 0 512 512" |
| 266 |
aria-hidden="true" |
| 267 |
role="img" |
| 268 |
width="1em" |
| 269 |
height="1em" |
| 270 |
> |
| 271 |
<path |
| 272 |
d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z" |
| 273 |
/> |
| 274 |
</svg> |
| 275 |
</span> |
| 276 |
</button> |
| 277 |
</div> |
| 278 |
</div> |
| 279 |
<br /> |
| 280 |
<div class="pf-v6-c-input-group"> |
| 281 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 282 |
<span class="pf-v6-c-form-control"> |
| 283 |
<input |
| 284 |
type="number" |
| 285 |
id="textInput14" |
| 286 |
name="textInput14" |
| 287 |
aria-label="Input example with plain unit" |
| 288 |
/> |
| 289 |
</span> |
| 290 |
</div> |
| 291 |
<div class="pf-v6-c-input-group__item pf-m-plain pf-m-box"> |
| 292 |
<span class="pf-v6-c-input-group__text">%</span> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
|
| 296 |
``` |
| 297 |
|
| 298 |
## Documentation |
| 299 |
|
| 300 |
### Accessibility |
| 301 |
|
| 302 |
When using the `.pf-v6-c-input-group` always ensure labels are used outside the input group with the `.pf-v6-screen-reader` class applied. You can also make use of the `aria-describedby`, `aria-label`, or `aria-labelledby` attributes. For more information on accessibility and forms see the [form component](/components/forms/form). |
| 303 |
|
| 304 |
| Attribute | Applied to | Outcome | |
| 305 |
| -- | -- | -- | |
| 306 |
| `aria-describedby` | `.pf-v6-c-form-control` | When using `.pf-v6-c-input-group__text` or `.pf-v6-c-input-group__action` make use of this on the input field. | |
| 307 |
|
| 308 |
### Usage |
| 309 |
|
| 310 |
| Class | Applied to | Outcome | |
| 311 |
| -- | -- | -- | |
| 312 |
| `.pf-v6-c-input-group` | `<div>` | Initiates the input group. **Required** | |
| 313 |
| `.pf-v6-c-input-group__item` | `<div>` | Initiates the input group item. | |
| 314 |
| `.pf-v6-c-input-group__text` | `<span>` | Initiates input group text. This should be used within `.pf-v6-c-input-group__item` to contain text. | |
| 315 |
| `.pf-m-plain` | `.pf-v6-c-input-group__item` | Removes the border from the input group element. | |
| 316 |
| `.pf-m-box` | `.pf-v6-c-input-group__item` | Adds appropriate styling for items that are not form controls. | |
| 317 |
| `.pf-m-fill` | `.pf-v6-c-input-group__item` | Allows the input group element to stretch to fill available space. | |
| 318 |
| `.pf-m-disabled` | `.pf-v6-c-input-group__item` | Adds disabled styling to match a disabled input within the input group. | |
| 319 |
| `.pf-m-search-expandable` | `.pf-v6-c-input-group` | Modifies an input group to be an expandable search input. **Note:** The expandable search input can be found in the [search input](/components/search-input/) component docs for react and [text input group](/components/text-input-group/html#search-input-group-expandable) component docs for core. | |
| 320 |
| `.pf-m-search-input` | `.pf-v6-c-input-group__item` | Identifies the text input an expandable search input. | |
| 321 |
| `.pf-m-search-expand` | `.pf-v6-c-input-group__item` | Identifies the expand button in an expandable search input. | |
| 322 |
| `.pf-m-search-action` | `.pf-v6-c-input-group__item` | Identifies actions adjacent to the search input when an expandable search input is expanded. | |