2021-10-22 19:32:39 +08:00
|
|
|
|
---
|
|
|
|
|
lang: en-US
|
2021-10-25 13:57:18 +08:00
|
|
|
|
type: component
|
2021-10-22 19:32:39 +08:00
|
|
|
|
---
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
# Slider
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
Drag the slider within a fixed range.
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
<style lang="scss">
|
|
|
|
|
.slider-demo-block {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
.el-slider {
|
|
|
|
|
flex: 1;
|
|
|
|
|
margin-left: 12px;
|
|
|
|
|
}
|
|
|
|
|
.demonstration {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: var(--el-text-color-secondary);
|
|
|
|
|
line-height: 44px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
& + .el-slider {
|
|
|
|
|
flex: 0 0 70%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
## Basic usage
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
The current value is displayed when the slider is being dragged.
|
|
|
|
|
|
|
|
|
|
:::demo Customize the initial value of the slider by setting the binding value.
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
slider/basic-usage
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
:::
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
## Discrete values
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
The options can be discrete.
|
|
|
|
|
|
|
|
|
|
:::demo Set step size with the `step` attribute. You can display breakpoints by setting the `show-stops` attribute.
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
slider/discrete-values
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
:::
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
## Slider with input box
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
Set value via a input box.
|
|
|
|
|
|
|
|
|
|
:::demo Set the `show-input` attribute to display an input box on the right.
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
slider/slider-with-input-box
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
:::
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
## Range selection
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
Selecting a range of values is supported.
|
|
|
|
|
|
|
|
|
|
:::demo Setting the `range` attribute activates range mode, where the binding value is an array made up of two boundary values.
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
slider/range-selection
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
:::
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
## Vertical mode
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
:::demo Setting the `vertical` attribute to `true` enables vertical mode. In vertical mode, the `height` attribute is required.
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
slider/vertical-mode
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
:::
|
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
## Show marks
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
|
|
:::demo Setting this `marks` attribute can show mark on slider.
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
|
slider/show-marks
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
## Attributes
|
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
|
| --------------------- | --------------------------------------------------------------------------------------------------------- | --------------- | ----------------------------- | ------- |
|
|
|
|
|
| model-value / v-model | binding value | number | — | 0 |
|
|
|
|
|
| min | minimum value | number | — | 0 |
|
|
|
|
|
| max | maximum value | number | — | 100 |
|
|
|
|
|
| disabled | whether Slider is disabled | boolean | — | false |
|
|
|
|
|
| step | step size | number | — | 1 |
|
|
|
|
|
| show-input | whether to display an input box, works when `range` is false | boolean | — | false |
|
|
|
|
|
| show-input-controls | whether to display control buttons when `show-input` is true | boolean | — | true |
|
|
|
|
|
| input-size | size of the input box | string | large / medium / small / mini | small |
|
|
|
|
|
| show-stops | whether to display breakpoints | boolean | — | false |
|
|
|
|
|
| show-tooltip | whether to display tooltip value | boolean | — | true |
|
|
|
|
|
| format-tooltip | format to display tooltip value | function(value) | — | — |
|
|
|
|
|
| range | whether to select a range | boolean | — | false |
|
|
|
|
|
| vertical | vertical mode | boolean | — | false |
|
|
|
|
|
| height | Slider height, required in vertical mode | string | — | — |
|
|
|
|
|
| label | label for screen reader | string | — | — |
|
|
|
|
|
| debounce | debounce delay when typing, in milliseconds, works when `show-input` is true | number | — | 300 |
|
|
|
|
|
| tooltip-class | custom class name for the tooltip | string | — | — |
|
|
|
|
|
| marks | marks, type of key must be `number` and must in closed interval `[min, max]`, each mark can custom style | object | — | — |
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
|
## Events
|
2020-10-26 10:56:14 +08:00
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
|
| Event Name | Description | Parameters |
|
|
|
|
|
| ---------- | ----------------------------------------------------------------------------------------------------------------- | -------------------- |
|
|
|
|
|
| change | triggers when the value changes (if the mouse is being dragged, this event only fires when the mouse is released) | value after changing |
|
|
|
|
|
| input | triggers when the data changes (It'll be emitted in real time during sliding) | value after changing |
|