1e41f4b71Sopenharmony_ci# slider
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **\<Slider>** component is used to quickly adjust settings, such as the volume and brightness.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Child Components
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciNot supported
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Attributes
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci| Name   | Type    | Default Value | Mandatory  | Description                                      |
18e41f4b71Sopenharmony_ci| ----- | ------ | ---- | ---- | ---------------------------------------- |
19e41f4b71Sopenharmony_ci| min   | number | 0    | No   | Minimum value of the slider.                              |
20e41f4b71Sopenharmony_ci| max   | number | 100  | No   | Maximum value of the slider.                              |
21e41f4b71Sopenharmony_ci| value | number | 0    | No   | Initial value of the slider.                              |
22e41f4b71Sopenharmony_ci| id    | string | -    | No   | Unique ID of the component.                                |
23e41f4b71Sopenharmony_ci| style | string | -    | No   | Style declaration of the component.                                |
24e41f4b71Sopenharmony_ci| class | string | -    | No   | Style class of the component, which is used to refer to a style table.                         |
25e41f4b71Sopenharmony_ci| ref   | string | -    | No   | Reference information of child elements, which is registered with the parent component on **$refs**.|
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci## Events
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| Name                | Parameter                               | Description            |
31e41f4b71Sopenharmony_ci| ------------------ | --------------------------------- | -------------- |
32e41f4b71Sopenharmony_ci| change             | ChangeEvent                       | Triggered when the value changes.|
33e41f4b71Sopenharmony_ci| click              | -                                 | Triggered when the component is clicked.    |
34e41f4b71Sopenharmony_ci| longpress          | -                                 | Triggered when the component is long pressed.    |
35e41f4b71Sopenharmony_ci| swipe<sup>5+</sup> | [SwipeEvent](js-lite-common-events.md) | Triggered when a user quickly swipes on the component.   |
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci  **Table 1** ChangeEvent
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci| Attribute                                      | Type    | Description           |
40e41f4b71Sopenharmony_ci| ---------------------------------------- | ------ | ------------- |
41e41f4b71Sopenharmony_ci| progress<sup>(deprecated<sup>5+</sup>)</sup> | string | Current value of the slider.|
42e41f4b71Sopenharmony_ci| value<sup>5+</sup>                       | number | Current value of the slider.|
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci## Styles
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci| Name                                | Type                                      | Default Value     | Mandatory  | Description                                      |
48e41f4b71Sopenharmony_ci| ---------------------------------- | ---------------------------------------- | -------- | ---- | ---------------------------------------- |
49e41f4b71Sopenharmony_ci| color                              | &lt;color&gt;                            | \#000000 | No   | Background color of the slider.                               |
50e41f4b71Sopenharmony_ci| selected-color                     | &lt;color&gt;                            | \#ffffff | No   | Selected color of the slider.                              |
51e41f4b71Sopenharmony_ci| width                              | &lt;length&gt; \| &lt;percentage&gt;<sup>5+</sup> | -        | No   | Component width.<br>If this attribute is not set, the default value **0** is used.       |
52e41f4b71Sopenharmony_ci| height                             | &lt;length&gt; \| &lt;percentage&gt;<sup>5+</sup> | -        | No   | Component height.<br>If this attribute is not set, the default value **0** is used.       |
53e41f4b71Sopenharmony_ci| padding                            | &lt;length&gt;                           | 0        | No   | Shorthand attribute to set the padding for all sides.<br>The attribute can have one to four values:<br>- If you set only one value, it specifies the padding for all the four sides.<br>- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.<br>- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.<br>- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).|
54e41f4b71Sopenharmony_ci| padding-[left\|top\|right\|bottom] | &lt;length&gt;                           | 0        | No   | Left, top, right, and bottom padding.                         |
55e41f4b71Sopenharmony_ci| margin                             | &lt;length&gt; \| &lt;percentage&gt;<sup>5+</sup> | 0        | No   | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:<br>- If you set only one value, it specifies the margin for all the four sides.<br>- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.<br>- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.<br>- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).|
56e41f4b71Sopenharmony_ci| margin-[left\|top\|right\|bottom]  | &lt;length&gt; \| &lt;percentage&gt;<sup>5+</sup> | 0        | No   | Left, top, right, and bottom margins.                         |
57e41f4b71Sopenharmony_ci| border-width                       | &lt;length&gt;                           | 0        | No   | Shorthand attribute to set the margin for all sides.                      |
58e41f4b71Sopenharmony_ci| border-color                       | &lt;color&gt;                            | black    | No   | Shorthand attribute to set the color for all borders.                      |
59e41f4b71Sopenharmony_ci| border-radius                      | &lt;length&gt;                           | -        | No   | Radius of round-corner borders.           |
60e41f4b71Sopenharmony_ci| background-color                   | &lt;color&gt;                            | -        | No   | Background color.                                 |
61e41f4b71Sopenharmony_ci| display                            | string                                   | flex     | No   | How and whether to display the box containing an element. Available values are as follows:<br>- **flex**: flexible layout<br>- **none**: not rendered|
62e41f4b71Sopenharmony_ci| [left\|top]                        | &lt;length&gt; \| &lt;percentage&gt;<sup>6+</sup> | -        | No   | Edge of the element.<br>- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.<br>- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.|
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci## Example
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci```html
67e41f4b71Sopenharmony_ci<!-- xxx.hml -->
68e41f4b71Sopenharmony_ci<div class="container">
69e41f4b71Sopenharmony_ci    <text>slider start value is {{startValue}}</text>
70e41f4b71Sopenharmony_ci    <text>slider current value is {{currentValue}}</text>
71e41f4b71Sopenharmony_ci    <text>slider end value is {{endValue}}</text>
72e41f4b71Sopenharmony_ci    <slider min="0" max="100" value="{{value}}" onchange="setValue" style="margin-top: 10%; width: 80%;height: 1%"></slider>
73e41f4b71Sopenharmony_ci</div>
74e41f4b71Sopenharmony_ci```
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci```css
77e41f4b71Sopenharmony_ci/* xxx.css */
78e41f4b71Sopenharmony_ci.container {
79e41f4b71Sopenharmony_ci  flex-direction: column;
80e41f4b71Sopenharmony_ci  justify-content: center;
81e41f4b71Sopenharmony_ci  align-items: center;
82e41f4b71Sopenharmony_ci  width: 100%;
83e41f4b71Sopenharmony_ci  height: 100%;
84e41f4b71Sopenharmony_ci}
85e41f4b71Sopenharmony_ci```
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci```javascript
88e41f4b71Sopenharmony_ci// xxx.js
89e41f4b71Sopenharmony_ciexport default {
90e41f4b71Sopenharmony_ci    data: {
91e41f4b71Sopenharmony_ci        value: 34,
92e41f4b71Sopenharmony_ci        startValue: 0,
93e41f4b71Sopenharmony_ci        currentValue: 0,
94e41f4b71Sopenharmony_ci        endValue: 100,
95e41f4b71Sopenharmony_ci    },
96e41f4b71Sopenharmony_ci    setValue(e) {
97e41f4b71Sopenharmony_ci        this.currentValue = e.value;
98e41f4b71Sopenharmony_ci    }
99e41f4b71Sopenharmony_ci}
100e41f4b71Sopenharmony_ci```
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci![slider](figures/slider-lite.png)
103