| 1 |
--- |
| 2 |
id: Slider |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-slider |
| 5 |
propComponents: ['Slider', 'SliderStepObject'] |
| 6 |
--- |
| 7 |
|
| 8 |
import { useState } from 'react'; |
| 9 |
import { Slider, Button, Content, ContentVariants } from '@patternfly/react-core'; |
| 10 |
import MinusIcon from '@patternfly/react-icons/dist/esm/icons/minus-icon'; |
| 11 |
import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; |
| 12 |
import LockIcon from '@patternfly/react-icons/dist/esm/icons/lock-icon'; |
| 13 |
import LockOpenIcon from '@patternfly/react-icons/dist/esm/icons/lock-open-icon'; |
| 14 |
|
| 15 |
## Examples |
| 16 |
|
| 17 |
### Discrete |
| 18 |
|
| 19 |
```ts file="./SliderDiscrete.tsx" |
| 20 |
|
| 21 |
``` |
| 22 |
|
| 23 |
### Continuous |
| 24 |
|
| 25 |
```ts file="./SliderContinuous.tsx" |
| 26 |
|
| 27 |
``` |
| 28 |
|
| 29 |
### Value input |
| 30 |
|
| 31 |
```ts file="./SliderValueInput.tsx" |
| 32 |
|
| 33 |
``` |
| 34 |
|
| 35 |
### Thumb value input |
| 36 |
|
| 37 |
```ts file="./SliderThumbValueInput.tsx" |
| 38 |
|
| 39 |
``` |
| 40 |
|
| 41 |
### Actions |
| 42 |
|
| 43 |
```ts file="./SliderActions.tsx" |
| 44 |
|
| 45 |
``` |
| 46 |
|
| 47 |
### Disabled |
| 48 |
|
| 49 |
```ts file="./SliderDisabled.tsx" |
| 50 |
|
| 51 |
``` |
| 52 |
|
| 53 |
## Types |
| 54 |
|
| 55 |
### SliderOnChangeEvent |
| 56 |
|
| 57 |
The slider's `onChange` prop accepts an `event` parameter of the following types: |
| 58 |
|
| 59 |
- `React.MouseEvent` |
| 60 |
- `React.KeyboardEvent` |
| 61 |
- `React.FormEvent<HTMLInputElement>` |
| 62 |
- `React.TouchEvent` |
| 63 |
- `React.FocusEvent<HTMLInputElement>` |
| 64 |
|
| 65 |
The `SliderOnChangeEvent` type is a union of the above event types, and can be imported and used in your code like in the following code snippet: |
| 66 |
|
| 67 |
```noLive |
| 68 |
import { Slider, SliderOnChangeEvent } from '@patternfly/react-core'; |
| 69 |
|
| 70 |
<Slider onChange={(event: SliderOnChangeEvent) => {}} /> |
| 71 |
``` |