| 1 |
--- |
| 2 |
id: Number input |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-number-input |
| 5 |
---## Examples |
| 6 |
|
| 7 |
### Default |
| 8 |
|
| 9 |
```html |
| 10 |
<div class="pf-v6-c-number-input"> |
| 11 |
<div class="pf-v6-c-input-group"> |
| 12 |
<div class="pf-v6-c-input-group__item"> |
| 13 |
<button |
| 14 |
class="pf-v6-c-button pf-m-control" |
| 15 |
type="button" |
| 16 |
aria-label="Minus" |
| 17 |
> |
| 18 |
<span class="pf-v6-c-button__icon"> |
| 19 |
<span class="pf-v6-c-number-input__icon"> |
| 20 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 21 |
</span> |
| 22 |
</span> |
| 23 |
</button> |
| 24 |
</div> |
| 25 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 26 |
<span class="pf-v6-c-form-control"> |
| 27 |
<input |
| 28 |
type="number" |
| 29 |
value="90" |
| 30 |
name="number-input-default-name" |
| 31 |
aria-label="Number input" |
| 32 |
/> |
| 33 |
</span> |
| 34 |
</div> |
| 35 |
<div class="pf-v6-c-input-group__item"> |
| 36 |
<button |
| 37 |
class="pf-v6-c-button pf-m-control" |
| 38 |
type="button" |
| 39 |
aria-label="Plus" |
| 40 |
> |
| 41 |
<span class="pf-v6-c-button__icon"> |
| 42 |
<span class="pf-v6-c-number-input__icon"> |
| 43 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 44 |
</span> |
| 45 |
</span> |
| 46 |
</button> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
|
| 51 |
``` |
| 52 |
|
| 53 |
### With unit |
| 54 |
|
| 55 |
```html |
| 56 |
<div class="pf-v6-c-number-input"> |
| 57 |
<div class="pf-v6-c-input-group"> |
| 58 |
<div class="pf-v6-c-input-group__item"> |
| 59 |
<button |
| 60 |
class="pf-v6-c-button pf-m-control" |
| 61 |
type="button" |
| 62 |
aria-label="Minus" |
| 63 |
> |
| 64 |
<span class="pf-v6-c-button__icon"> |
| 65 |
<span class="pf-v6-c-number-input__icon"> |
| 66 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 67 |
</span> |
| 68 |
</span> |
| 69 |
</button> |
| 70 |
</div> |
| 71 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 72 |
<span class="pf-v6-c-form-control"> |
| 73 |
<input |
| 74 |
type="number" |
| 75 |
value="90" |
| 76 |
name="number-input-unit-name" |
| 77 |
aria-label="Number input" |
| 78 |
/> |
| 79 |
</span> |
| 80 |
</div> |
| 81 |
<div class="pf-v6-c-input-group__item"> |
| 82 |
<button |
| 83 |
class="pf-v6-c-button pf-m-control" |
| 84 |
type="button" |
| 85 |
aria-label="Plus" |
| 86 |
> |
| 87 |
<span class="pf-v6-c-button__icon"> |
| 88 |
<span class="pf-v6-c-number-input__icon"> |
| 89 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 90 |
</span> |
| 91 |
</span> |
| 92 |
</button> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
<span class="pf-v6-c-number-input__unit">%</span> |
| 96 |
</div> |
| 97 |
<br /> |
| 98 |
<br /> |
| 99 |
<div class="pf-v6-c-number-input"> |
| 100 |
<span class="pf-v6-c-number-input__unit">$</span> |
| 101 |
|
| 102 |
<div class="pf-v6-c-input-group"> |
| 103 |
<div class="pf-v6-c-input-group__item"> |
| 104 |
<button |
| 105 |
class="pf-v6-c-button pf-m-control" |
| 106 |
type="button" |
| 107 |
aria-label="Minus" |
| 108 |
> |
| 109 |
<span class="pf-v6-c-button__icon"> |
| 110 |
<span class="pf-v6-c-number-input__icon"> |
| 111 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 112 |
</span> |
| 113 |
</span> |
| 114 |
</button> |
| 115 |
</div> |
| 116 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 117 |
<span class="pf-v6-c-form-control"> |
| 118 |
<input |
| 119 |
type="number" |
| 120 |
value="1.00" |
| 121 |
name="number-input-unit2-name" |
| 122 |
aria-label="Number input" |
| 123 |
/> |
| 124 |
</span> |
| 125 |
</div> |
| 126 |
<div class="pf-v6-c-input-group__item"> |
| 127 |
<button |
| 128 |
class="pf-v6-c-button pf-m-control" |
| 129 |
type="button" |
| 130 |
aria-label="Plus" |
| 131 |
> |
| 132 |
<span class="pf-v6-c-button__icon"> |
| 133 |
<span class="pf-v6-c-number-input__icon"> |
| 134 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 135 |
</span> |
| 136 |
</span> |
| 137 |
</button> |
| 138 |
</div> |
| 139 |
</div> |
| 140 |
</div> |
| 141 |
|
| 142 |
``` |
| 143 |
|
| 144 |
### With unit and lower threshold reached |
| 145 |
|
| 146 |
```html |
| 147 |
<div class="pf-v6-c-number-input"> |
| 148 |
<div class="pf-v6-c-input-group"> |
| 149 |
<div class="pf-v6-c-input-group__item"> |
| 150 |
<button |
| 151 |
class="pf-v6-c-button pf-m-control" |
| 152 |
type="button" |
| 153 |
aria-label="Minus" |
| 154 |
disabled |
| 155 |
> |
| 156 |
<span class="pf-v6-c-button__icon"> |
| 157 |
<span class="pf-v6-c-number-input__icon"> |
| 158 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 159 |
</span> |
| 160 |
</span> |
| 161 |
</button> |
| 162 |
</div> |
| 163 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 164 |
<span class="pf-v6-c-form-control"> |
| 165 |
<input |
| 166 |
type="number" |
| 167 |
value="0" |
| 168 |
min="0" |
| 169 |
name="number-input-unit-lower-threshold-name" |
| 170 |
aria-label="Number input" |
| 171 |
/> |
| 172 |
</span> |
| 173 |
</div> |
| 174 |
<div class="pf-v6-c-input-group__item"> |
| 175 |
<button |
| 176 |
class="pf-v6-c-button pf-m-control" |
| 177 |
type="button" |
| 178 |
aria-label="Plus" |
| 179 |
> |
| 180 |
<span class="pf-v6-c-button__icon"> |
| 181 |
<span class="pf-v6-c-number-input__icon"> |
| 182 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 183 |
</span> |
| 184 |
</span> |
| 185 |
</button> |
| 186 |
</div> |
| 187 |
</div> |
| 188 |
<span class="pf-v6-c-number-input__unit">%</span> |
| 189 |
</div> |
| 190 |
|
| 191 |
``` |
| 192 |
|
| 193 |
### With unit and upper threshold reached |
| 194 |
|
| 195 |
```html |
| 196 |
<div class="pf-v6-c-number-input"> |
| 197 |
<div class="pf-v6-c-input-group"> |
| 198 |
<div class="pf-v6-c-input-group__item"> |
| 199 |
<button |
| 200 |
class="pf-v6-c-button pf-m-control" |
| 201 |
type="button" |
| 202 |
aria-label="Minus" |
| 203 |
> |
| 204 |
<span class="pf-v6-c-button__icon"> |
| 205 |
<span class="pf-v6-c-number-input__icon"> |
| 206 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 207 |
</span> |
| 208 |
</span> |
| 209 |
</button> |
| 210 |
</div> |
| 211 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 212 |
<span class="pf-v6-c-form-control"> |
| 213 |
<input |
| 214 |
type="number" |
| 215 |
value="100" |
| 216 |
max="100" |
| 217 |
name="number-input-unit-upper-threshold-name" |
| 218 |
aria-label="Number input" |
| 219 |
/> |
| 220 |
</span> |
| 221 |
</div> |
| 222 |
<div class="pf-v6-c-input-group__item"> |
| 223 |
<button |
| 224 |
class="pf-v6-c-button pf-m-control" |
| 225 |
type="button" |
| 226 |
aria-label="Plus" |
| 227 |
disabled |
| 228 |
> |
| 229 |
<span class="pf-v6-c-button__icon"> |
| 230 |
<span class="pf-v6-c-number-input__icon"> |
| 231 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 232 |
</span> |
| 233 |
</span> |
| 234 |
</button> |
| 235 |
</div> |
| 236 |
</div> |
| 237 |
<span class="pf-v6-c-number-input__unit">%</span> |
| 238 |
</div> |
| 239 |
|
| 240 |
``` |
| 241 |
|
| 242 |
### Disabled |
| 243 |
|
| 244 |
```html |
| 245 |
<div class="pf-v6-c-number-input"> |
| 246 |
<div class="pf-v6-c-input-group"> |
| 247 |
<div class="pf-v6-c-input-group__item"> |
| 248 |
<button |
| 249 |
class="pf-v6-c-button pf-m-control" |
| 250 |
type="button" |
| 251 |
aria-label="Minus" |
| 252 |
disabled |
| 253 |
> |
| 254 |
<span class="pf-v6-c-button__icon"> |
| 255 |
<span class="pf-v6-c-number-input__icon"> |
| 256 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 257 |
</span> |
| 258 |
</span> |
| 259 |
</button> |
| 260 |
</div> |
| 261 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 262 |
<span class="pf-v6-c-form-control pf-m-disabled"> |
| 263 |
<input |
| 264 |
disabled |
| 265 |
type="number" |
| 266 |
value="100" |
| 267 |
name="number-input-disabled-name" |
| 268 |
aria-label="Number input" |
| 269 |
/> |
| 270 |
</span> |
| 271 |
</div> |
| 272 |
<div class="pf-v6-c-input-group__item"> |
| 273 |
<button |
| 274 |
class="pf-v6-c-button pf-m-control" |
| 275 |
type="button" |
| 276 |
aria-label="Plus" |
| 277 |
disabled |
| 278 |
> |
| 279 |
<span class="pf-v6-c-button__icon"> |
| 280 |
<span class="pf-v6-c-number-input__icon"> |
| 281 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 282 |
</span> |
| 283 |
</span> |
| 284 |
</button> |
| 285 |
</div> |
| 286 |
</div> |
| 287 |
<span class="pf-v6-c-number-input__unit">%</span> |
| 288 |
</div> |
| 289 |
|
| 290 |
``` |
| 291 |
|
| 292 |
### With status |
| 293 |
|
| 294 |
```html |
| 295 |
<div class="pf-v6-c-number-input pf-m-status"> |
| 296 |
<div class="pf-v6-c-input-group"> |
| 297 |
<div class="pf-v6-c-input-group__item"> |
| 298 |
<button |
| 299 |
class="pf-v6-c-button pf-m-control" |
| 300 |
type="button" |
| 301 |
aria-label="Minus" |
| 302 |
> |
| 303 |
<span class="pf-v6-c-button__icon"> |
| 304 |
<span class="pf-v6-c-number-input__icon"> |
| 305 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 306 |
</span> |
| 307 |
</span> |
| 308 |
</button> |
| 309 |
</div> |
| 310 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 311 |
<span class="pf-v6-c-form-control"> |
| 312 |
<input |
| 313 |
type="number" |
| 314 |
value="90" |
| 315 |
name="number-input-status-name" |
| 316 |
aria-label="Number input" |
| 317 |
/> |
| 318 |
</span> |
| 319 |
</div> |
| 320 |
<div class="pf-v6-c-input-group__item"> |
| 321 |
<button |
| 322 |
class="pf-v6-c-button pf-m-control" |
| 323 |
type="button" |
| 324 |
aria-label="Plus" |
| 325 |
> |
| 326 |
<span class="pf-v6-c-button__icon"> |
| 327 |
<span class="pf-v6-c-number-input__icon"> |
| 328 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 329 |
</span> |
| 330 |
</span> |
| 331 |
</button> |
| 332 |
</div> |
| 333 |
</div> |
| 334 |
</div> |
| 335 |
<br /> |
| 336 |
<br /> |
| 337 |
<div class="pf-v6-c-number-input pf-m-status"> |
| 338 |
<div class="pf-v6-c-input-group"> |
| 339 |
<div class="pf-v6-c-input-group__item"> |
| 340 |
<button |
| 341 |
class="pf-v6-c-button pf-m-control" |
| 342 |
type="button" |
| 343 |
aria-label="Minus" |
| 344 |
> |
| 345 |
<span class="pf-v6-c-button__icon"> |
| 346 |
<span class="pf-v6-c-number-input__icon"> |
| 347 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 348 |
</span> |
| 349 |
</span> |
| 350 |
</button> |
| 351 |
</div> |
| 352 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 353 |
<span class="pf-v6-c-form-control pf-m-warning"> |
| 354 |
<input |
| 355 |
type="number" |
| 356 |
value="90" |
| 357 |
name="number-input-status-warning-name" |
| 358 |
aria-label="Number input" |
| 359 |
/> |
| 360 |
<span class="pf-v6-c-form-control__utilities"> |
| 361 |
<span class="pf-v6-c-form-control__icon pf-m-status"> |
| 362 |
<i class="fas fa-exclamation-triangle" aria-hidden="true"></i> |
| 363 |
</span> |
| 364 |
</span> |
| 365 |
</span> |
| 366 |
</div> |
| 367 |
<div class="pf-v6-c-input-group__item"> |
| 368 |
<button |
| 369 |
class="pf-v6-c-button pf-m-control" |
| 370 |
type="button" |
| 371 |
aria-label="Plus" |
| 372 |
> |
| 373 |
<span class="pf-v6-c-button__icon"> |
| 374 |
<span class="pf-v6-c-number-input__icon"> |
| 375 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 376 |
</span> |
| 377 |
</span> |
| 378 |
</button> |
| 379 |
</div> |
| 380 |
</div> |
| 381 |
</div> |
| 382 |
|
| 383 |
``` |
| 384 |
|
| 385 |
### Varying sizes |
| 386 |
|
| 387 |
```html |
| 388 |
<div |
| 389 |
class="pf-v6-c-number-input" |
| 390 |
style="--pf-v6-c-number-input--c-form-control--width-chars: 1;" |
| 391 |
> |
| 392 |
<div class="pf-v6-c-input-group"> |
| 393 |
<div class="pf-v6-c-input-group__item"> |
| 394 |
<button |
| 395 |
class="pf-v6-c-button pf-m-control" |
| 396 |
type="button" |
| 397 |
aria-label="Minus" |
| 398 |
> |
| 399 |
<span class="pf-v6-c-button__icon"> |
| 400 |
<span class="pf-v6-c-number-input__icon"> |
| 401 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 402 |
</span> |
| 403 |
</span> |
| 404 |
</button> |
| 405 |
</div> |
| 406 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 407 |
<span class="pf-v6-c-form-control"> |
| 408 |
<input |
| 409 |
type="number" |
| 410 |
value="1" |
| 411 |
name="number-input-sizes-name" |
| 412 |
aria-label="Number input" |
| 413 |
/> |
| 414 |
</span> |
| 415 |
</div> |
| 416 |
<div class="pf-v6-c-input-group__item"> |
| 417 |
<button |
| 418 |
class="pf-v6-c-button pf-m-control" |
| 419 |
type="button" |
| 420 |
aria-label="Plus" |
| 421 |
> |
| 422 |
<span class="pf-v6-c-button__icon"> |
| 423 |
<span class="pf-v6-c-number-input__icon"> |
| 424 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 425 |
</span> |
| 426 |
</span> |
| 427 |
</button> |
| 428 |
</div> |
| 429 |
</div> |
| 430 |
</div> |
| 431 |
<br /> |
| 432 |
<br /> |
| 433 |
<div |
| 434 |
class="pf-v6-c-number-input" |
| 435 |
style="--pf-v6-c-number-input--c-form-control--width-chars: 10;" |
| 436 |
> |
| 437 |
<div class="pf-v6-c-input-group"> |
| 438 |
<div class="pf-v6-c-input-group__item"> |
| 439 |
<button |
| 440 |
class="pf-v6-c-button pf-m-control" |
| 441 |
type="button" |
| 442 |
aria-label="Minus" |
| 443 |
> |
| 444 |
<span class="pf-v6-c-button__icon"> |
| 445 |
<span class="pf-v6-c-number-input__icon"> |
| 446 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 447 |
</span> |
| 448 |
</span> |
| 449 |
</button> |
| 450 |
</div> |
| 451 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 452 |
<span class="pf-v6-c-form-control"> |
| 453 |
<input |
| 454 |
type="number" |
| 455 |
value="1234567890" |
| 456 |
name="number-input-sizes2-name" |
| 457 |
aria-label="Number input" |
| 458 |
/> |
| 459 |
</span> |
| 460 |
</div> |
| 461 |
<div class="pf-v6-c-input-group__item"> |
| 462 |
<button |
| 463 |
class="pf-v6-c-button pf-m-control" |
| 464 |
type="button" |
| 465 |
aria-label="Plus" |
| 466 |
> |
| 467 |
<span class="pf-v6-c-button__icon"> |
| 468 |
<span class="pf-v6-c-number-input__icon"> |
| 469 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 470 |
</span> |
| 471 |
</span> |
| 472 |
</button> |
| 473 |
</div> |
| 474 |
</div> |
| 475 |
</div> |
| 476 |
<br /> |
| 477 |
<br /> |
| 478 |
<div |
| 479 |
class="pf-v6-c-number-input" |
| 480 |
style="--pf-v6-c-number-input--c-form-control--width-chars: 5;" |
| 481 |
> |
| 482 |
<div class="pf-v6-c-input-group"> |
| 483 |
<div class="pf-v6-c-input-group__item"> |
| 484 |
<button |
| 485 |
class="pf-v6-c-button pf-m-control" |
| 486 |
type="button" |
| 487 |
aria-label="Minus" |
| 488 |
> |
| 489 |
<span class="pf-v6-c-button__icon"> |
| 490 |
<span class="pf-v6-c-number-input__icon"> |
| 491 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 492 |
</span> |
| 493 |
</span> |
| 494 |
</button> |
| 495 |
</div> |
| 496 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 497 |
<span class="pf-v6-c-form-control"> |
| 498 |
<input |
| 499 |
type="number" |
| 500 |
value="5" |
| 501 |
name="number-input-sizes3-name" |
| 502 |
aria-label="Number input" |
| 503 |
/> |
| 504 |
</span> |
| 505 |
</div> |
| 506 |
<div class="pf-v6-c-input-group__item"> |
| 507 |
<button |
| 508 |
class="pf-v6-c-button pf-m-control" |
| 509 |
type="button" |
| 510 |
aria-label="Plus" |
| 511 |
> |
| 512 |
<span class="pf-v6-c-button__icon"> |
| 513 |
<span class="pf-v6-c-number-input__icon"> |
| 514 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 515 |
</span> |
| 516 |
</span> |
| 517 |
</button> |
| 518 |
</div> |
| 519 |
</div> |
| 520 |
</div> |
| 521 |
<br /> |
| 522 |
<br /> |
| 523 |
<div |
| 524 |
class="pf-v6-c-number-input" |
| 525 |
style="--pf-v6-c-number-input--c-form-control--width-chars: 5;" |
| 526 |
> |
| 527 |
<div class="pf-v6-c-input-group"> |
| 528 |
<div class="pf-v6-c-input-group__item"> |
| 529 |
<button |
| 530 |
class="pf-v6-c-button pf-m-control" |
| 531 |
type="button" |
| 532 |
aria-label="Minus" |
| 533 |
> |
| 534 |
<span class="pf-v6-c-button__icon"> |
| 535 |
<span class="pf-v6-c-number-input__icon"> |
| 536 |
<i class="fas fa-minus" aria-hidden="true"></i> |
| 537 |
</span> |
| 538 |
</span> |
| 539 |
</button> |
| 540 |
</div> |
| 541 |
<div class="pf-v6-c-input-group__item pf-m-fill"> |
| 542 |
<span class="pf-v6-c-form-control"> |
| 543 |
<input |
| 544 |
type="number" |
| 545 |
value="12345" |
| 546 |
name="number-input-sizes4-name" |
| 547 |
aria-label="Number input" |
| 548 |
/> |
| 549 |
</span> |
| 550 |
</div> |
| 551 |
<div class="pf-v6-c-input-group__item"> |
| 552 |
<button |
| 553 |
class="pf-v6-c-button pf-m-control" |
| 554 |
type="button" |
| 555 |
aria-label="Plus" |
| 556 |
> |
| 557 |
<span class="pf-v6-c-button__icon"> |
| 558 |
<span class="pf-v6-c-number-input__icon"> |
| 559 |
<i class="fas fa-plus" aria-hidden="true"></i> |
| 560 |
</span> |
| 561 |
</span> |
| 562 |
</button> |
| 563 |
</div> |
| 564 |
</div> |
| 565 |
</div> |
| 566 |
|
| 567 |
``` |
| 568 |
|
| 569 |
## Documentation |
| 570 |
|
| 571 |
### Accessibility |
| 572 |
|
| 573 |
| Attribute | Applied to | Outcome | |
| 574 |
| -- | -- | -- | |
| 575 |
| `aria-label="Plus"`, `aria-label="Minus"` | `.pf-v6-c-button.pf-m-control` | Provides an accessible name for the outer plus/minus buttons. **Required** | |
| 576 |
| `min` | `input[type="number"].pf-v6-c-form-control` | Provides an optional minimum value for the input. | |
| 577 |
| `max` | `input[type="number"].pf-v6-c-form-control` | Provides an optional maximum value for the input. | |
| 578 |
|
| 579 |
### Usage |
| 580 |
|
| 581 |
| Class | Applied to | Outcome | |
| 582 |
| -- | -- | -- | |
| 583 |
| `.pf-v6-c-number-input` | `<div>` | Initiates the number input component. | |
| 584 |
| `.pf-v6-c-number-input__icon` | `<span>` | Initiates the number input icon. | |
| 585 |
| `.pf-v6-c-number-input__unit` | `<span>` | Initiates the number input unit. | |
| 586 |
| `.pf-m-status` | `.pf-v6-c-number-input` | Modifies the width to create enough space for a status icon to be included in the form control portion of the number input. **Required** if a status icon may be shown, even if the icon is not currently shown. | |
| 587 |
| `--pf-v6-c-number-input--c-form-control--width-chars` | `.pf-v6-c-number-input` | Specifies the number of characters to show in the input. | |