| 1 |
--- |
| 2 |
id: Number input |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-number-input |
| 5 |
propComponents: ['NumberInput'] |
| 6 |
--- |
| 7 |
|
| 8 |
import { Fragment, useReducer, useState } from 'react'; |
| 9 |
|
| 10 |
## Examples |
| 11 |
|
| 12 |
### Default |
| 13 |
|
| 14 |
```ts file="./NumberInputDefault.tsx" |
| 15 |
``` |
| 16 |
|
| 17 |
### With unit |
| 18 |
|
| 19 |
```ts file="./NumberInputUnit.tsx" |
| 20 |
``` |
| 21 |
|
| 22 |
### With unit and thresholds |
| 23 |
|
| 24 |
To enable a user entered value to snap to the nearest threshold if the entered input is out of bounds, define the blur event handler. |
| 25 |
|
| 26 |
```ts file="./NumberInputUnitThreshold.tsx" |
| 27 |
``` |
| 28 |
|
| 29 |
### Disabled |
| 30 |
|
| 31 |
```ts file="./NumberInputDisabled.tsx" |
| 32 |
``` |
| 33 |
|
| 34 |
### With status |
| 35 |
|
| 36 |
```ts file="./NumberInputWithStatus.tsx" |
| 37 |
``` |
| 38 |
|
| 39 |
### Varying sizes |
| 40 |
|
| 41 |
```ts file="./NumberInputVaryingSizes.tsx" |
| 42 |
``` |
| 43 |
|
| 44 |
### Custom increment/decrement |
| 45 |
|
| 46 |
```ts file="./NumberInputCustomStep.tsx" |
| 47 |
``` |
| 48 |
|
| 49 |
### Custom increment/decrement and thresholds |
| 50 |
|
| 51 |
```ts file="./NumberInputCustomStepAndThreshold.tsx" |
| 52 |
``` |