2020-08-13 11:47:56 +08:00
# Slider
## Demos
### Size variants
2021-10-20 01:11:27 +08:00
Available size variants for the [`ui` ](#props-ui ) prop: `s` / `m` .
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/slider/size.vue" ]]
### Read-only/disabled
2021-10-20 01:11:27 +08:00
Use the [`readonly` ](#props-readonly ) prop to set a slider read-only. Use the [`disabled` ](#props-disabled ) prop to set a slider disabled.
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/slider/editable.vue" ]]
### Steps
Use the `step` to make value change by specified step value when clicking spinner buttons, or pressing < kbd > ▴</ kbd > or < kbd > ▾</ kbd > .
[[ demo src="/demo/slider/steps.vue" ]]
### Range
2021-10-20 01:11:27 +08:00
Use the [`max` ](#props-max ) / [`min` ](#props-min ) props to specify the values at both ends of the slider.
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/slider/range.vue" ]]
### Secondary bar
2021-10-20 01:11:27 +08:00
Use the [`secondary-progress` ](#props-secondary-progress ) prop to specify a secondary progress bar.
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/slider/buffer.vue" ]]
### Customization
2021-10-20 01:11:27 +08:00
Use the [`thumb` ](#slots-thumb ) / [`tip` ](#slots-tip ) slots to customize the content of slider thumb and tooltip.
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/slider/variant.vue" ]]
## API
### Props
| Name | Type | Default | Description |
| -- | -- | -- | -- |
2021-10-20 01:11:27 +08:00
| ``ui`` | `string=` | - | [^ui] |
| ``value`` | `*|Array<*>` | - | [^value] |
| ``secondary-progress`` | `number | Array<number>` | `0` | Secondary progress value. |
| ``min`` | `number` | `0` | The minimun value after `value` is processed by the `parse` function. |
| ``max`` | `number` | `1` | The maximum value after `value` is processed by the `parse` function. |
| ``step`` | `number` | `0` | The step value after `value` is processed by the `parse` function. |
| ``mark`` | `boolean` | `false` | Whether to display step marks. |
| ``parse`` | `function` | `val => val` | The parse function to transform input value. |
| ``format`` | `function` | `val => val` | The format function to transform output value. |
2020-08-13 11:47:56 +08:00
^^^ui
Style variants.
+++Enum values
| Value | Description |
| -- | -- |
| `s` | Small. |
| `m` | Medium. |
+++
^^^
^^^value
The value of the slider.
By default the type is `number` and the value should between `min` and `max` after parsed by the `parse` function.
When being the type of `Array<number>` , multiple thumbs will be rendered corresponding to each value.
:::tip
2021-10-20 01:11:27 +08:00
When `parse` and `format` are specified, values can be of any type, and `parse` should transform the value to `number` and `format` should transform the value to the same type as the [`value` ](#props-value ) prop. `parse` and `format` only need to take care of single values instead of arrays and the component itself will apply transformation on multiple values if necessary.
2020-08-13 11:47:56 +08:00
:::
^^^
### Slots
| Name | Description |
| -- | -- |
2021-10-20 01:11:27 +08:00
| ``track`` | The track of the slider. Displays a bar by default. |
| ``tip-label`` | The tooltip content. Displays the current `value` or its item by default. |
| ``thumb`` | [^slot-thumb] |
| ``tip`` | [^slot-tip] |
2020-08-13 11:47:56 +08:00
2020-12-22 16:33:30 +08:00
^^^slot-thumb
2020-08-13 11:47:56 +08:00
The thumb(s) of the slider. Displays a round button by default.
+++Scope properties
| Name | Type | Description |
| -- | -- | -- |
| `index` | `number` | The index of current thumb. |
| `focus` | `boolean` | Whether current thumb is focused. |
| `hover` | `boolean` | Whether user is pointing current thumb. |
| `dragging` | `boolean` | Whether the current thumb is being dragged. |
+++
^^^
2020-12-22 16:33:30 +08:00
^^^slot-tip
2020-08-13 11:47:56 +08:00
The entire tooltip for each thumb. Displays a `Tooltip` component with `value` as its content by default.
+++Scope properties
| Name | Type | Description |
| -- | -- | -- |
| `target` | `HTMLElement` | The rendered `Element` for current thumb. |
| `open` | `boolean` | Whether there is any active thumb. |
| `active-index` | `boolean` | The index of the current active thumb. |
+++
^^^
### Events
| Name | Description |
| -- | -- |
2021-10-20 01:11:27 +08:00
| ``input`` | [^event-input] |
2020-08-13 11:47:56 +08:00
^^^event-input
:::badges
`v-model`
:::
Triggered after the value changed. The callback parameter type is `(value: *)` , where `value` is the new value (transformed by the `format` function).
^^^