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 7. 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## APIs
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciSlider(options?: SliderOptions)
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**Parameters** 
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci| Name | Type                                   | Mandatory | Description              |
28e41f4b71Sopenharmony_ci| ------- | --------------------------------------- | ---- | ------------------ |
29e41f4b71Sopenharmony_ci| options | [SliderOptions](#slideroptions)  | No  | Parameters of the slider. |
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci## SliderOptions
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
38e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
39e41f4b71Sopenharmony_ci| value | number | No | Current progress.<br>Default value: same as the value of **min**<br>Since API version 10, this parameter supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md). |
40e41f4b71Sopenharmony_ci| min | number | No | Minimum value.<br>Default value: **0** |
41e41f4b71Sopenharmony_ci| max | number | No | Maximum value.<br>Default value: **100**<br>**NOTE**<br>If the value of **min** is greater than or equal to the value of **max**, the **min** value defaults to **0**, and the **max** value defaults to **100**.<br>If the value is not within the [min, max] range, the value of **min** or **max** is used, whichever is closer. |
42e41f4b71Sopenharmony_ci| step | number | No | Step of the slider.<br>Default value: **1**<br>Value range: [0.01, max]<br>**NOTE**<br>If this parameter is set to a value less than 0 or greater than the value of **max**, the default value is used. |
43e41f4b71Sopenharmony_ci| style | [SliderStyle](#sliderstyle)  | No | Style of the slider thumb and track.<br>Default value: **SliderStyle.OutSet** |
44e41f4b71Sopenharmony_ci| direction<sup>8+</sup> | [Axis](ts-appendix-enums.md#axis) | No | Whether the slider moves horizontally or vertically.<br>Default value: **Axis.Horizontal** |
45e41f4b71Sopenharmony_ci| reverse<sup>8+</sup> | boolean | No | Whether the slider values are reversed. By default, the values increase from left to right for a horizontal slider and from top to bottom for a vertical slider.<br>Default value: **false** |
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci## SliderStyle
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci| Name | Description |
52e41f4b71Sopenharmony_ci| -------- | -------- |
53e41f4b71Sopenharmony_ci| OutSet | The thumb is on the track.<br>**Atomic service API**: This API can be used in atomic services since API version 11. |
54e41f4b71Sopenharmony_ci| InSet | The thumb is in the track.<br>**Atomic service API**: This API can be used in atomic services since API version 11. |
55e41f4b71Sopenharmony_ci| NONE<sup>12+</sup> | There is no thumb.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci## Attributes
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ciAll the [universal attributes](ts-universal-attributes-size.md) except **responseRegion** are supported 
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci### blockColor
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ciblockColor(value: ResourceColor)
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ciColor of the thumb.
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ciWhen **SliderBlockType.DEFAULT** is used, **blockColor** sets the color of the round thumb.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ciWhen **SliderBlockType.IMAGE** is used, **blockColor** does not work as the thumb has no fill color.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciWhen **SliderBlockType.SHAPE** is used, **blockColor** sets the color of the thumb in a custom shape.
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Parameters** 
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci| Name | Type                                      | Mandatory | Description                               |
82e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------------------------------- |
83e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Color of the thumb.<br>Default value: **'#ffffff'** |
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci### trackColor
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_citrackColor(value: ResourceColor | LinearGradient)
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ciSets the background color of the track.
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci**LinearGradient** is supported since API version 12.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**Parameters** 
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci| Name | Type                                                        | Mandatory | Description                                                        |
102e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
103e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient<sup>12+</sup>](ts-basic-components-datapanel.md#lineargradient10)  | Yes  | Background color of the track.<br>**NOTE**<br>With gradient color settings, if the color stop values are invalid or if the color stops are empty, the gradient effect will not be applied.<br>Default value: **'#19182431'**<br>The LinearGradient type cannot be used in atomic services. |
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci### selectedColor
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ciselectedColor(value: ResourceColor)
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ciSets the color of the portion of the track between the minimum value and the thumb.
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Parameters** 
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci| Name | Type                                      | Mandatory | Description                                         |
120e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | --------------------------------------------- |
121e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Color of the portion of the track between the minimum value and the thumb.<br>Default value: **'#007dff'** |
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci### showSteps
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_cishowSteps(value: boolean)
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ciSets whether to display the current step.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**Parameters** 
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci| Name | Type   | Mandatory | Description                                      |
138e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------ |
139e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to display the current step.<br>Default value: **false** |
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci### showTips
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_cishowTips(value: boolean, content?: ResourceStr)
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciSets whether to display a tooltip when the user drags the slider.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ciWhen **direction** is set to **Axis.Horizontal**, the tooltip is displayed right above the slider; if there is insufficient space above, it will be displayed below. When **direction** is set to **Axis.Vertical**, the tooltip is displayed on the left of the slider; if there is insufficient space on the left, it will be displayed on the right. If the margins are not set or are set to small values, the tooltip may be truncated.
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ciThe drawing area of the tooltip is the overlay of the slider.
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci**Parameters** 
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci| Name               | Type                                  | Mandatory | Description                                      |
160e41f4b71Sopenharmony_ci| --------------------- | -------------------------------------- | ---- | ------------------------------------------ |
161e41f4b71Sopenharmony_ci| value                 | boolean                                | Yes  | Whether to display a tooltip when the user drags the slider.<br>Default value: **false** |
162e41f4b71Sopenharmony_ci| content<sup>10+</sup> | [ResourceStr](ts-types.md#resourcestr) | No  | Content of the tooltip. By default, the tooltip shows the current percentage value.  |
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci### trackThickness<sup>8+</sup>
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_citrackThickness(value: Length)
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ciSets the thickness of the track. If the value is less than or equal to 0, the default value is used.
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ciTo ensure [SliderStyle](#sliderstyle) works as expected for the thumb and track, [blockSize](#blocksize10) should increase or decrease proportionally with **trackThickness**.
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ciSpecially, when **style** is **[SliderStyle](#sliderstyle).OutSet**, trackThickness: [blockSize](#blocksize10) = 1:4; when **style** is **[SliderStyle](#sliderstyle).InSet**, trackThickness: [blockSize](#blocksize10) = 5:3.
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ciIn changing the value of **trackThickness**, if it or the value of [blockSize](#blocksize10) exceeds the width or height of the slider, the default value is used. (When **style** is **[SliderStyle](#sliderstyle).OutSet**, it is possible that only the value of [blockSize](#blocksize10) exceeds the height of the slider.)
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**Parameters** 
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci| Name | Type                        | Mandatory | Description                                                        |
185e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------------------------------------------ |
186e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | Yes  | Thickness of the track.<br>Default value: 4.0vp when **style** is set to **[SliderStyle](#sliderstyle).OutSet**; 20.0vp when **style** is set to **[SliderStyle](#sliderstyle).InSet** |
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci### blockBorderColor<sup>10+</sup>
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ciblockBorderColor(value: ResourceColor)
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ciBorder color of the slider in the block direction.
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ciWhen **SliderBlockType.DEFAULT** is used, **blockBorderColor** sets the border color of the round slider.
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ciWhen **SliderBlockType.IMAGE** is used, **blockBorderColor** does not work as the slider has no border.
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ciWhen **SliderBlockType.SHAPE** is used, **blockBorderColor** sets the border color of the slider in a custom shape.
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**Parameters** 
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci| Name | Type                                      | Mandatory | Description                                  |
207e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | -------------------------------------- |
208e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Border color of the slider in the block direction.<br>Default value: **'#00000000'** |
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci### blockBorderWidth<sup>10+</sup>
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ciblockBorderWidth(value: Length)
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ciBorder width of the slider in the block direction.
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ciWhen **SliderBlockType.DEFAULT** is used, **blockBorderWidth** sets the border width of the round slider.
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ciWhen **SliderBlockType.IMAGE** is used, **blockBorderWidth** does not work as the slider has no border.
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ciWWhen **SliderBlockType.SHAPE** is used, **blockBorderWidth** sets the border width of the slider in a custom shape.
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**Parameters** 
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci| Name | Type                        | Mandatory | Description          |
229e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | -------------- |
230e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | Yes  | Border width of the slider in the block direction. |
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci### stepColor<sup>10+</sup>
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_cistepColor(value: ResourceColor)
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ciStep color.
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**Parameters** 
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci| Name | Type                                      | Mandatory | Description                              |
245e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ---------------------------------- |
246e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Step color.<br>Default value: **'#19182431'** |
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci### trackBorderRadius<sup>10+</sup>
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_citrackBorderRadius(value: Length)
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ciSets the radius of the rounded corner of the track.
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci**Parameters** 
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci| Name | Type                        | Mandatory | Description                            |
261e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | -------------------------------- |
262e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | Yes  | Radius of the rounded corner of the track.<br>Default value: **'2vp'** |
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci### selectedBorderRadius<sup>12+</sup>
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ciselectedBorderRadius(value: Dimension)
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ciSet the corner radius of the selected (highlighted) part of the slider.
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**Parameters** 
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci| Name | Type                        | Mandatory | Description                            |
277e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | -------------------------------- |
278e41f4b71Sopenharmony_ci| value  | [Dimension](ts-types.md#dimension10)| Yes  | Corner radius of the selected part of the slider.<br>Default value: same as the corner radius of the background when **style** is set to **SliderStyle.InSet** or **SliderStyle.OutSet**; 0 when **style** is set to **SliderStyle.NONE**|
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci### blockSize<sup>10+</sup>
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ciblockSize(value: SizeOptions)
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ciSize of the slider in the block direction.
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci**Parameters** 
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci| Name | Type                                  | Mandatory | Description                                                        |
293e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
294e41f4b71Sopenharmony_ci| value  | [SizeOptions](ts-types.md#sizeoptions) | Yes  | Size of the slider in the block direction.<br>Default value: {width: 16, height: 16} when **style** is set to **[SliderStyle](#sliderstyle).OutSet**; {width: 12, height: 12} when **style** is set to **[SliderStyle](#sliderstyle).InSet**<br>If the set **blockSize** has different width and height values, the smaller value is taken. If one or both of the width and height values are less than or equal to 0, the default value is used instead. |
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci### blockStyle<sup>10+</sup>
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ciblockStyle(value: SliderBlockStyle)
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ciStyle of the slider in the block direction.
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci**Parameters** 
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci| Name | Type                                           | Mandatory | Description                                                        |
309e41f4b71Sopenharmony_ci| ------ | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
310e41f4b71Sopenharmony_ci| value  | [SliderBlockStyle](#sliderblockstyle10)  | Yes  | Style of the slider in the block direction.<br>Default value: **SliderBlockType.DEFAULT**, indicating the round slider. |
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci### stepSize<sup>10+</sup>
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_cistepSize(value: Length)
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ciSets the step size (diameter). If the value is 0, the step size is not displayed. If the value is less than 0, the default value is used.
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci**Parameters** 
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci| Name | Type                        | Mandatory | Description                                 |
325e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------------------- |
326e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | Yes  | Step size (diameter).<br>Default value: **'4vp'** |
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci### minLabel<sup>(deprecated)</sup>
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ciminLabel(value: string)
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ciSets the minimum value.
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use **min** instead.
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci**Parameters** 
339e41f4b71Sopenharmony_ci
340e41f4b71Sopenharmony_ci| Name | Type  | Mandatory | Description    |
341e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------- |
342e41f4b71Sopenharmony_ci| value  | string | Yes  | Minimum value. |
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci### maxLabel<sup>(deprecated)</sup>
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_cimaxLabel(value: string)
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_ciSets the maximum value.
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use **max** instead.
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci**Parameters** 
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci| Name | Type  | Mandatory | Description    |
357e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------- |
358e41f4b71Sopenharmony_ci| value  | string | Yes  | Maximum value. |
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci>  **NOTE** 
361e41f4b71Sopenharmony_ci>
362e41f4b71Sopenharmony_ci>  - By default, the slider has no padding.
363e41f4b71Sopenharmony_ci>  - A horizontal slider is displayed in the center with the following default settings: 40 vp height, width equal with that of the parent container, 10 vp left and right margins not covered by any padding (if set).
364e41f4b71Sopenharmony_ci>  - A vertical slider is displayed in the center with the following default settings: 40 vp width, height equal with that of the parent container, 6 vp top and bottom margins not covered by any padding (if set).
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci### sliderInteractionMode<sup>12+</sup>
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_cisliderInteractionMode(value: SliderInteraction)
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ciSets the interaction mode between the user and the slider.
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci**Parameters**
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci| Name | Type                                             | Mandatory | Description                                                        |
379e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
380e41f4b71Sopenharmony_ci| value  | [SliderInteraction](#sliderinteraction12) | Yes  | Interaction mode between the user and the slider.<br> Default value: **SliderInteraction.SLIDE_AND_CLICK** |
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci### minResponsiveDistance<sup>12+</sup>
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ciminResponsiveDistance(value: number)
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ciSets the minimum distance required for the slider to respond.
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci**Parameters**
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci| Name | Type   | Mandatory | Description                                      |
395e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------ |
396e41f4b71Sopenharmony_ci| value  | number | Yes  | Minimum distance required for the slider to respond. The slider will only respond and move when the sliding distance exceeds this threshold.<br>**NOTE**<br>The unit is the same as that of **min** and **max**.<br>If the value is less than 0, greater than the result of (max - min), or invalid, the default value is used.<br>Default value: **0** |
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci### contentModifier<sup>12+</sup>
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_cicontentModifier(modifier: ContentModifier\<SliderConfiguration>)
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ciCreates a content modifier.
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci**Parameters**
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci| Name | Type                                         | Mandatory | Description                                            |
411e41f4b71Sopenharmony_ci| ------ | --------------------------------------------- | ---- | ------------------------------------------------ |
412e41f4b71Sopenharmony_ci| modifier  | [ContentModifier\<SliderConfiguration>](#sliderconfiguration12) | Yes  | Content modifier to apply to the slider.<br>**modifier**: content modifier. You need a custom class to implement the **ContentModifier** API. |
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci>  **NOTE**
415e41f4b71Sopenharmony_ci>
416e41f4b71Sopenharmony_ci>  - If **contentModifier** is set, then clicks and swipes within the custom area will not trigger the **onChange** event of the original slider.
417e41f4b71Sopenharmony_ci>  - The **onChange** event of the original slider can only be triggered when the **triggerChange** function is called with the correct parameter value.
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci### slideRange<sup>12+</sup>
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_cislideRange(value: SlideRange)
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ciSets the slide range.
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ci**Parameters**
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci| Name | Type                                       | Mandatory | Description         |
432e41f4b71Sopenharmony_ci| ------ |-------------------------------------------| ---- |-------------|
433e41f4b71Sopenharmony_ci| value  | SlideRange                                | Yes  | Slide range.   |
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci## SliderBlockStyle<sup>10+</sup>
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ciDescribes the style of the slider in the block direction.
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci| Name | Type                                                        | Mandatory | Description                                                        |
442e41f4b71Sopenharmony_ci| ----- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
443e41f4b71Sopenharmony_ci| type  | [SliderBlockType](#sliderblocktype10)                | Yes  | Type of the slider in the block direction.<br>Default value: **SliderBlockType.DEFAULT**, indicating the round slider. |
444e41f4b71Sopenharmony_ci| image | [ResourceStr](ts-types.md#resourcestr)                       | No  | Image resource of the slider.<br>The area size for displaying the image is subject to the **blockSize** attribute. Be mindful of the image size when selecting an image. |
445e41f4b71Sopenharmony_ci| shape | [Circle](ts-drawing-components-circle.md) \| [Ellipse](ts-drawing-components-ellipse.md) \| [Path](ts-drawing-components-path.md) \| [Rect](ts-drawing-components-rect.md)  | No  | Custom shape of the slider.                                  |
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci## SliderBlockType<sup>10+</sup>
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ciEnumerates the types of the slider in the block direction.
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ci| Name   | Description                  |
454e41f4b71Sopenharmony_ci| ------- | ---------------------- |
455e41f4b71Sopenharmony_ci| DEFAULT | Round slider.  |
456e41f4b71Sopenharmony_ci| IMAGE   | Slider with an image background.  |
457e41f4b71Sopenharmony_ci| SHAPE   | Slider in a custom shape. |
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci## SliderInteraction<sup>12+</sup>
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ciEnumerates the interaction modes between the user and the slider.
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ci| Name    | Description                           |
466e41f4b71Sopenharmony_ci| ------ | ----------------------------- |
467e41f4b71Sopenharmony_ci| SLIDE_AND_CLICK | Users can drag the slider or touch the track to move the slider. The slider moves as soon as the mouse or finger is pressed.|
468e41f4b71Sopenharmony_ci| SLIDE_ONLY | Users are not allowed to move the slider by touching the slider.|
469e41f4b71Sopenharmony_ci| SLIDE_AND_CLICK_UP | Users can drag the slider or touch the track to move the slider. The slider moves when the mouse is released or finger is lifted, if the release/lift position coincides with the screen press position.|
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci## SlideRange<sup>12+</sup>
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ciDefines the callback type used in **SlideRange**.
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci| Name | Type    | Mandatory | Description          |
478e41f4b71Sopenharmony_ci|----|--------| ---- |--------------|
479e41f4b71Sopenharmony_ci| from | number | Yes | Start of the slide range. |
480e41f4b71Sopenharmony_ci| to | number | Yes | End of the slide range. |
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci>  **NOTE**
483e41f4b71Sopenharmony_ci>
484e41f4b71Sopenharmony_ci>  - Currently, this API takes effect only when **MIN** ≤ **from** ≤ **to** ≤ **MAX** (the values of **MIN** and **MAX** do not depend on the values set, but on the actual values that take effect).
485e41f4b71Sopenharmony_ci>  - You can set only **from** or **to**, or you can set both**from** and **to** at the same time.
486e41f4b71Sopenharmony_ci>  - When the API is effective, if the set **from** value is between the adjacent multiples of **step**, then **from** takes the value of the left interval multiple of **step** or **MIN** as the corrected value.
487e41f4b71Sopenharmony_ci>  - When the API is effective, if the set **to** value is between the adjacent multiples of **step**, then **to** takes the value of the right interval multiple of **step** or **MAX** as the corrected value.
488e41f4b71Sopenharmony_ci>  - After **from** and **to** have taken their corrected values, when **value** is **undefined** or **null**, it takes the same value as **from**; when **value** is a number type, and if **value** ≤ **from**, then it takes **from**; if **value** > **to**, then it takes **to**.
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci## Events
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ciIn addition to the [universal events](ts-universal-events-click.md), the following attributes are supported.
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci### onChange
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_cionChange(callback: (value: number, mode: SliderChangeMode) =&gt; void)
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ciInvoked when the slider is dragged or clicked.
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ciThe **Begin** and **End** states are triggered when the slider is clicked with a gesture. The **Moving** and **Click** states are triggered when the value of **value** changes.
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ciIf the coherent action is a drag action, the **Click** state will not be triggered.
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci**Parameters** 
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci| Name | Type                                         | Mandatory | Description                                                        |
513e41f4b71Sopenharmony_ci| ------ | --------------------------------------------- | ---- | ------------------------------------------------------------ |
514e41f4b71Sopenharmony_ci| value  | number                                        | Yes  | Current sliding progress. Its range of changes corresponds to the array of step sizes. If the return value contains decimals, you can use the **number.toFixed()** API to process the data to the expected precision. |
515e41f4b71Sopenharmony_ci| mode   | [SliderChangeMode](#sliderchangemode) | Yes  | State triggered by the event.                                      |
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci## SliderChangeMode
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci| Name | Value | Description |
524e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
525e41f4b71Sopenharmony_ci| Begin | 0 | The user touches or clicks the thumb. |
526e41f4b71Sopenharmony_ci| Moving | 1 | The user is dragging the slider. |
527e41f4b71Sopenharmony_ci| End | 2 | The user stops dragging the slider by lifting their finger or releasing the mouse device.<br>**NOTE**<br>The trigger occurs when an invalid value is restored to the default value, that is, when the value is set to less than **min** or greater than **max**. |
528e41f4b71Sopenharmony_ci| Click    | 3    | The user moves the thumb by touching or clicking the track. |
529e41f4b71Sopenharmony_ci
530e41f4b71Sopenharmony_ci## SliderConfiguration<sup>12+</sup>
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ciYou need a custom class to implement the **ContentModifier** API.
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci| Name | Type   | Description             |
537e41f4b71Sopenharmony_ci| ------ | ------ | ---------------- |
538e41f4b71Sopenharmony_ci| value | number | Current progress. |
539e41f4b71Sopenharmony_ci| min | number | Minimum value. |
540e41f4b71Sopenharmony_ci| max | number | Maximum value. |
541e41f4b71Sopenharmony_ci| step | number | Step of the slider. |
542e41f4b71Sopenharmony_ci| triggerChange | [SliderTriggerChangeCallback](#slidertriggerchangecallback12) | Triggers slider changes. |
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci## SliderTriggerChangeCallback<sup>12+</sup>
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ciDefines the callback type used in **SliderConfiguration**.
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci| Name | Type   | Mandatory | Description             |
551e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- |
552e41f4b71Sopenharmony_ci| value | number | Yes | Current progress. |
553e41f4b71Sopenharmony_ci| mode | [SliderChangeMode](#sliderchangemode) | Yes | State triggered by the event. |
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci## Example
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci### Example 1
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_ci```ts
560e41f4b71Sopenharmony_ci// xxx.ets
561e41f4b71Sopenharmony_ci@Entry
562e41f4b71Sopenharmony_ci@Component
563e41f4b71Sopenharmony_cistruct SliderExample {
564e41f4b71Sopenharmony_ci  @State outSetValueOne: number = 40
565e41f4b71Sopenharmony_ci  @State inSetValueOne: number = 40
566e41f4b71Sopenharmony_ci  @State noneValueOne: number = 40
567e41f4b71Sopenharmony_ci  @State outSetValueTwo: number = 40
568e41f4b71Sopenharmony_ci  @State inSetValueTwo: number = 40
569e41f4b71Sopenharmony_ci  @State vOutSetValueOne: number = 40
570e41f4b71Sopenharmony_ci  @State vInSetValueOne: number = 40
571e41f4b71Sopenharmony_ci  @State vOutSetValueTwo: number = 40
572e41f4b71Sopenharmony_ci  @State vInSetValueTwo: number = 40
573e41f4b71Sopenharmony_ci
574e41f4b71Sopenharmony_ci  build() {
575e41f4b71Sopenharmony_ci    Column({ space: 8 }) {
576e41f4b71Sopenharmony_ci      Text('outset slider').fontSize(9).fontColor(0xCCCCCC).width('90%').margin(15)
577e41f4b71Sopenharmony_ci      Row() {
578e41f4b71Sopenharmony_ci        Slider({
579e41f4b71Sopenharmony_ci          value: this.outSetValueOne,
580e41f4b71Sopenharmony_ci          min: 0,
581e41f4b71Sopenharmony_ci          max: 100,
582e41f4b71Sopenharmony_ci          style: SliderStyle.OutSet
583e41f4b71Sopenharmony_ci        })
584e41f4b71Sopenharmony_ci          .showTips(true)
585e41f4b71Sopenharmony_ci          .onChange((value: number, mode: SliderChangeMode) => {
586e41f4b71Sopenharmony_ci            this.outSetValueOne = value
587e41f4b71Sopenharmony_ci            console.info('value:' + value + 'mode:' + mode.toString())
588e41f4b71Sopenharmony_ci          })
589e41f4b71Sopenharmony_ci        // toFixed(0) converts the return value of the slider to an integer.
590e41f4b71Sopenharmony_ci        Text(this.outSetValueOne.toFixed(0)).fontSize(12)
591e41f4b71Sopenharmony_ci      }
592e41f4b71Sopenharmony_ci      .width('80%')
593e41f4b71Sopenharmony_ci      Row() {
594e41f4b71Sopenharmony_ci        Slider({
595e41f4b71Sopenharmony_ci          value: this.outSetValueTwo,
596e41f4b71Sopenharmony_ci          step: 10,
597e41f4b71Sopenharmony_ci          style: SliderStyle.OutSet
598e41f4b71Sopenharmony_ci        })
599e41f4b71Sopenharmony_ci          .showSteps(true)
600e41f4b71Sopenharmony_ci          .onChange((value: number, mode: SliderChangeMode) => {
601e41f4b71Sopenharmony_ci            this.outSetValueTwo = value
602e41f4b71Sopenharmony_ci            console.info('value:' + value + 'mode:' + mode.toString())
603e41f4b71Sopenharmony_ci          })
604e41f4b71Sopenharmony_ci        Text(this.outSetValueTwo.toFixed(0)).fontSize(12)
605e41f4b71Sopenharmony_ci      }
606e41f4b71Sopenharmony_ci      .width('80%')
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci      Text('inset slider').fontSize(9).fontColor(0xCCCCCC).width('90%').margin(15)
609e41f4b71Sopenharmony_ci      Row() {
610e41f4b71Sopenharmony_ci        Slider({
611e41f4b71Sopenharmony_ci          value: this.inSetValueOne,
612e41f4b71Sopenharmony_ci          min: 0,
613e41f4b71Sopenharmony_ci          max: 100,
614e41f4b71Sopenharmony_ci          style: SliderStyle.InSet
615e41f4b71Sopenharmony_ci        })
616e41f4b71Sopenharmony_ci          .blockColor('#191970')
617e41f4b71Sopenharmony_ci          .trackColor('#ADD8E6')
618e41f4b71Sopenharmony_ci          .selectedColor('#4169E1')
619e41f4b71Sopenharmony_ci          .showTips(true)
620e41f4b71Sopenharmony_ci          .onChange((value: number, mode: SliderChangeMode) => {
621e41f4b71Sopenharmony_ci            this.inSetValueOne = value
622e41f4b71Sopenharmony_ci            console.info('value:' + value + 'mode:' + mode.toString())
623e41f4b71Sopenharmony_ci          })
624e41f4b71Sopenharmony_ci        Text(this.inSetValueOne.toFixed(0)).fontSize(12)
625e41f4b71Sopenharmony_ci      }
626e41f4b71Sopenharmony_ci      .width('80%')
627e41f4b71Sopenharmony_ci      Row() {
628e41f4b71Sopenharmony_ci        Slider({
629e41f4b71Sopenharmony_ci          value: this.inSetValueTwo,
630e41f4b71Sopenharmony_ci          step: 10,
631e41f4b71Sopenharmony_ci          style: SliderStyle.InSet
632e41f4b71Sopenharmony_ci        })
633e41f4b71Sopenharmony_ci          .blockColor('#191970')
634e41f4b71Sopenharmony_ci          .trackColor('#ADD8E6')
635e41f4b71Sopenharmony_ci          .selectedColor('#4169E1')
636e41f4b71Sopenharmony_ci          .showSteps(true)
637e41f4b71Sopenharmony_ci          .onChange((value: number, mode: SliderChangeMode) => {
638e41f4b71Sopenharmony_ci            this.inSetValueTwo = value
639e41f4b71Sopenharmony_ci            console.info('value:' + value + 'mode:' + mode.toString())
640e41f4b71Sopenharmony_ci          })
641e41f4b71Sopenharmony_ci        Text(this.inSetValueTwo.toFixed(0)).fontSize(12)
642e41f4b71Sopenharmony_ci      }
643e41f4b71Sopenharmony_ci      .width('80%')
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci      Text('none slider').fontSize(9).fontColor(0xCCCCCC).width('90%').margin(15)
646e41f4b71Sopenharmony_ci      Row() {
647e41f4b71Sopenharmony_ci        Slider({
648e41f4b71Sopenharmony_ci          value: this.noneValueOne,
649e41f4b71Sopenharmony_ci          min: 0,
650e41f4b71Sopenharmony_ci          max: 100,
651e41f4b71Sopenharmony_ci          style: SliderStyle.NONE
652e41f4b71Sopenharmony_ci        })
653e41f4b71Sopenharmony_ci          .blockColor('#191970')
654e41f4b71Sopenharmony_ci          .trackColor('#ADD8E6')
655e41f4b71Sopenharmony_ci          .selectedColor('#4169E1')
656e41f4b71Sopenharmony_ci          .showTips(true)
657e41f4b71Sopenharmony_ci          .onChange((value: number, mode: SliderChangeMode) => {
658e41f4b71Sopenharmony_ci            this.noneValueOne = value
659e41f4b71Sopenharmony_ci            console.info('value:' + value + 'mode:' + mode.toString())
660e41f4b71Sopenharmony_ci          })
661e41f4b71Sopenharmony_ci        Text(this.noneValueOne.toFixed(0)).fontSize(12)
662e41f4b71Sopenharmony_ci      }
663e41f4b71Sopenharmony_ci      .width('80%')
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci      Row() {
666e41f4b71Sopenharmony_ci        Column() {
667e41f4b71Sopenharmony_ci          Text('vertical outset slider').fontSize(9).fontColor(0xCCCCCC).width('50%').margin(15)
668e41f4b71Sopenharmony_ci          Row() {
669e41f4b71Sopenharmony_ci            Text().width('10%')
670e41f4b71Sopenharmony_ci            Slider({
671e41f4b71Sopenharmony_ci              value: this.vOutSetValueOne,
672e41f4b71Sopenharmony_ci              style: SliderStyle.OutSet,
673e41f4b71Sopenharmony_ci              direction: Axis.Vertical
674e41f4b71Sopenharmony_ci            })
675e41f4b71Sopenharmony_ci              .blockColor('#191970')
676e41f4b71Sopenharmony_ci              .trackColor('#ADD8E6')
677e41f4b71Sopenharmony_ci              .selectedColor('#4169E1')
678e41f4b71Sopenharmony_ci              .showTips(true)
679e41f4b71Sopenharmony_ci              .onChange((value: number, mode: SliderChangeMode) => {
680e41f4b71Sopenharmony_ci                this.vOutSetValueOne = value
681e41f4b71Sopenharmony_ci                console.info('value:' + value + 'mode:' + mode.toString())
682e41f4b71Sopenharmony_ci              })
683e41f4b71Sopenharmony_ci            Slider({
684e41f4b71Sopenharmony_ci              value: this.vOutSetValueTwo,
685e41f4b71Sopenharmony_ci              step: 10,
686e41f4b71Sopenharmony_ci              style: SliderStyle.OutSet,
687e41f4b71Sopenharmony_ci              direction: Axis.Vertical
688e41f4b71Sopenharmony_ci            })
689e41f4b71Sopenharmony_ci              .blockColor('#191970')
690e41f4b71Sopenharmony_ci              .trackColor('#ADD8E6')
691e41f4b71Sopenharmony_ci              .selectedColor('#4169E1')
692e41f4b71Sopenharmony_ci              .showSteps(true)
693e41f4b71Sopenharmony_ci              .onChange((value: number, mode: SliderChangeMode) => {
694e41f4b71Sopenharmony_ci                this.vOutSetValueTwo = value
695e41f4b71Sopenharmony_ci                console.info('value:' + value + 'mode:' + mode.toString())
696e41f4b71Sopenharmony_ci              })
697e41f4b71Sopenharmony_ci          }
698e41f4b71Sopenharmony_ci        }.width('50%').height(300)
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci        Column() {
701e41f4b71Sopenharmony_ci          Text('vertical inset slider').fontSize(9).fontColor(0xCCCCCC).width('50%').margin(15)
702e41f4b71Sopenharmony_ci          Row() {
703e41f4b71Sopenharmony_ci            Slider({
704e41f4b71Sopenharmony_ci              value: this.vInSetValueOne,
705e41f4b71Sopenharmony_ci              style: SliderStyle.InSet,
706e41f4b71Sopenharmony_ci              direction: Axis.Vertical,
707e41f4b71Sopenharmony_ci              reverse: true // By default, at the top of the vertical slider is the min value and at the bottom is the max value. Therefore, if you want to slide from bottom to top, set reverse to true.
708e41f4b71Sopenharmony_ci            })
709e41f4b71Sopenharmony_ci              .showTips(true)
710e41f4b71Sopenharmony_ci              .onChange((value: number, mode: SliderChangeMode) => {
711e41f4b71Sopenharmony_ci                this.vInSetValueOne = value
712e41f4b71Sopenharmony_ci                console.info('value:' + value + 'mode:' + mode.toString())
713e41f4b71Sopenharmony_ci              })
714e41f4b71Sopenharmony_ci            Slider({
715e41f4b71Sopenharmony_ci              value: this.vInSetValueTwo,
716e41f4b71Sopenharmony_ci              step: 10,
717e41f4b71Sopenharmony_ci              style: SliderStyle.InSet,
718e41f4b71Sopenharmony_ci              direction: Axis.Vertical,
719e41f4b71Sopenharmony_ci              reverse: true
720e41f4b71Sopenharmony_ci            })
721e41f4b71Sopenharmony_ci              .showSteps(true)
722e41f4b71Sopenharmony_ci              .onChange((value: number, mode: SliderChangeMode) => {
723e41f4b71Sopenharmony_ci                this.vInSetValueTwo = value
724e41f4b71Sopenharmony_ci                console.info('value:' + value + 'mode:' + mode.toString())
725e41f4b71Sopenharmony_ci              })
726e41f4b71Sopenharmony_ci          }
727e41f4b71Sopenharmony_ci        }.width('50%').height(300)
728e41f4b71Sopenharmony_ci      }
729e41f4b71Sopenharmony_ci    }.width('100%')
730e41f4b71Sopenharmony_ci  }
731e41f4b71Sopenharmony_ci}
732e41f4b71Sopenharmony_ci```
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci![slider](figures/slider.gif)
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci### Example 2
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci```ts
739e41f4b71Sopenharmony_ci@Entry
740e41f4b71Sopenharmony_ci@Component
741e41f4b71Sopenharmony_cistruct SliderExample {
742e41f4b71Sopenharmony_ci  @State tipsValue: number = 40
743e41f4b71Sopenharmony_ci
744e41f4b71Sopenharmony_ci  build() {
745e41f4b71Sopenharmony_ci    Column({ space: 8 }) {
746e41f4b71Sopenharmony_ci      Text('block').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%')
747e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.OutSet, value: 40 })
748e41f4b71Sopenharmony_ci        .blockSize({ width: 40, height: 40 })
749e41f4b71Sopenharmony_ci        .blockBorderColor(Color.Red)
750e41f4b71Sopenharmony_ci        .blockBorderWidth(5)
751e41f4b71Sopenharmony_ci      Divider()
752e41f4b71Sopenharmony_ci      Text('step').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%')
753e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.InSet, value: 40, step: 10 })
754e41f4b71Sopenharmony_ci        .showSteps(true)
755e41f4b71Sopenharmony_ci        .stepSize(8)
756e41f4b71Sopenharmony_ci        .stepColor(Color.Yellow)
757e41f4b71Sopenharmony_ci      Divider()
758e41f4b71Sopenharmony_ci      Text('track').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%')
759e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.InSet, value: 40 })
760e41f4b71Sopenharmony_ci        .trackBorderRadius(2)
761e41f4b71Sopenharmony_ci      Divider()
762e41f4b71Sopenharmony_ci      Text('selected').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%')
763e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.InSet, value: 40 })
764e41f4b71Sopenharmony_ci        .selectedBorderRadius(2)
765e41f4b71Sopenharmony_ci      Divider()
766e41f4b71Sopenharmony_ci      Text('blockStyle').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%')
767e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.OutSet, value: 40 })
768e41f4b71Sopenharmony_ci        .blockStyle({ type: SliderBlockType.DEFAULT })
769e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.OutSet, value: 40 })
770e41f4b71Sopenharmony_ci        .blockStyle({ type: SliderBlockType.IMAGE, image: $r('sys.media.ohos_app_icon') })
771e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.OutSet, value: 40 })
772e41f4b71Sopenharmony_ci        .blockSize({ width: '60px', height: '60px' })
773e41f4b71Sopenharmony_ci        .blockColor(Color.Red)
774e41f4b71Sopenharmony_ci        .blockStyle({ type: SliderBlockType.SHAPE, shape: new Path({ commands: 'M60 60 M30 30 L15 56 L45 56 Z' }) })
775e41f4b71Sopenharmony_ci      Divider()
776e41f4b71Sopenharmony_ci      Text('tips').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%')
777e41f4b71Sopenharmony_ci      Slider({ style: SliderStyle.InSet, value: this.tipsValue })
778e41f4b71Sopenharmony_ci        .showTips(true, this.tipsValue.toFixed())
779e41f4b71Sopenharmony_ci        .onChange(value => {
780e41f4b71Sopenharmony_ci          this.tipsValue = value
781e41f4b71Sopenharmony_ci        })
782e41f4b71Sopenharmony_ci    }
783e41f4b71Sopenharmony_ci  }
784e41f4b71Sopenharmony_ci}
785e41f4b71Sopenharmony_ci```
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci![slider_2](figures/slider_2.png)
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci### Example 3
792e41f4b71Sopenharmony_ci
793e41f4b71Sopenharmony_ci```ts
794e41f4b71Sopenharmony_ci// xxx.ets
795e41f4b71Sopenharmony_ci// This example implements a slider with a customcontent area through a style builder. When the Increase button is clicked, the progress bar increases based on the step size set by the original slider. When the Decrease button is clicked, the progress bar decreases, and the original slider's onChange event is triggered.
796e41f4b71Sopenharmony_ci@Builder function buildSlider(config: SliderConfiguration) {
797e41f4b71Sopenharmony_ci  Row() {
798e41f4b71Sopenharmony_ci    Column({space: 30}) {
799e41f4b71Sopenharmony_ci      Progress({value: config.value, total: config.max, type:ProgressType.Ring})
800e41f4b71Sopenharmony_ci        .margin({ top:20 })
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci      Button ('Increase').onClick () => {
803e41f4b71Sopenharmony_ci        config.value = config.value + config.step
804e41f4b71Sopenharmony_ci        config.triggerChange(config.value, SliderChangeMode.Click)
805e41f4b71Sopenharmony_ci      })
806e41f4b71Sopenharmony_ci        .width(100)
807e41f4b71Sopenharmony_ci        .height(25)
808e41f4b71Sopenharmony_ci        .fontSize(10)
809e41f4b71Sopenharmony_ci        .enabled(config.value<config.max)
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci      Button ('Decrease').onClick () => {
812e41f4b71Sopenharmony_ci        config.value=config.value-config.step
813e41f4b71Sopenharmony_ci        config.triggerChange(config.value, SliderChangeMode.Click)
814e41f4b71Sopenharmony_ci      })
815e41f4b71Sopenharmony_ci        .width(100)
816e41f4b71Sopenharmony_ci        .height(25)
817e41f4b71Sopenharmony_ci        .fontSize(10)
818e41f4b71Sopenharmony_ci        .enabled(config.value>config.min)
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci      Slider({
821e41f4b71Sopenharmony_ci        value: config.value,
822e41f4b71Sopenharmony_ci        min: config.min,
823e41f4b71Sopenharmony_ci        max: config.max,
824e41f4b71Sopenharmony_ci        step:config.step,
825e41f4b71Sopenharmony_ci      })
826e41f4b71Sopenharmony_ci        .width(config.max)
827e41f4b71Sopenharmony_ci        .visibility((config.contentModifier as MySliderStyle).showSlider?Visibility.Visible:Visibility.Hidden)
828e41f4b71Sopenharmony_ci        .showSteps(true)
829e41f4b71Sopenharmony_ci        .onChange((value: number, mode: SliderChangeMode) => {
830e41f4b71Sopenharmony_ci          config.triggerChange(value, mode)
831e41f4b71Sopenharmony_ci        })
832e41f4b71Sopenharmony_ci      Text('Current state: '+ ((config.contentModifier as MySliderStyle).sliderChangeMode==0?"Begin"
833e41f4b71Sopenharmony_ci        :((config.contentModifier as MySliderStyle).sliderChangeMode==1?"Moving"
834e41f4b71Sopenharmony_ci          :((config.contentModifier as MySliderStyle).sliderChangeMode==2?"End"
835e41f4b71Sopenharmony_ci            :((config.contentModifier as MySliderStyle).sliderChangeMode==3?"Click":"None")))))
836e41f4b71Sopenharmony_ci        .fontSize(10)
837e41f4b71Sopenharmony_ci      Text('Progress: '+ config.value)
838e41f4b71Sopenharmony_ci        .fontSize(10)
839e41f4b71Sopenharmony_ci      Text('Min: ' + config.min)
840e41f4b71Sopenharmony_ci        .fontSize(10)
841e41f4b71Sopenharmony_ci      Text('Max: ' + config.max)
842e41f4b71Sopenharmony_ci        .fontSize(10)
843e41f4b71Sopenharmony_ci      Text ('Step: ' + config.step)
844e41f4b71Sopenharmony_ci        .fontSize(10)
845e41f4b71Sopenharmony_ci    }
846e41f4b71Sopenharmony_ci    .width('80%')
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ci  }
849e41f4b71Sopenharmony_ci  .width('100%')
850e41f4b71Sopenharmony_ci}
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ciclass MySliderStyle implements ContentModifier<SliderConfiguration> {
853e41f4b71Sopenharmony_ci  showSlider:boolean=true
854e41f4b71Sopenharmony_ci  sliderChangeMode:number=0
855e41f4b71Sopenharmony_ci  constructor(showSlider: boolean,sliderChangeMode:number) {
856e41f4b71Sopenharmony_ci    this.showSlider = showSlider
857e41f4b71Sopenharmony_ci    this.sliderChangeMode = sliderChangeMode
858e41f4b71Sopenharmony_ci  }
859e41f4b71Sopenharmony_ci  applyContent() : WrappedBuilder<[SliderConfiguration]> {
860e41f4b71Sopenharmony_ci    return wrapBuilder(buildSlider)
861e41f4b71Sopenharmony_ci  }
862e41f4b71Sopenharmony_ci}
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci@Entry
866e41f4b71Sopenharmony_ci@Component
867e41f4b71Sopenharmony_cistruct SliderExample {
868e41f4b71Sopenharmony_ci  @State showSlider:boolean=true
869e41f4b71Sopenharmony_ci  @State sliderValue: number = 0
870e41f4b71Sopenharmony_ci  @State sliderMin: number = 10
871e41f4b71Sopenharmony_ci  @State sliderMax: number = 100
872e41f4b71Sopenharmony_ci  @State sliderStep: number = 20
873e41f4b71Sopenharmony_ci  @State sliderChangeMode: number = 0
874e41f4b71Sopenharmony_ci
875e41f4b71Sopenharmony_ci  build() {
876e41f4b71Sopenharmony_ci    Column({ space: 8 }) {
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci      Row() {
879e41f4b71Sopenharmony_ci        Slider({
880e41f4b71Sopenharmony_ci          value: this.sliderValue,
881e41f4b71Sopenharmony_ci          min: this.sliderMin,
882e41f4b71Sopenharmony_ci          max: this.sliderMax,
883e41f4b71Sopenharmony_ci          step:this.sliderStep,
884e41f4b71Sopenharmony_ci        })
885e41f4b71Sopenharmony_ci          .showSteps(true)
886e41f4b71Sopenharmony_ci          .onChange((value: number, mode: SliderChangeMode) => {
887e41f4b71Sopenharmony_ci            this.sliderValue = value
888e41f4b71Sopenharmony_ci            this.sliderChangeMode=mode
889e41f4b71Sopenharmony_ci            console.info(' [SliderLog] value:' + value + 'mode:' + mode.toString())
890e41f4b71Sopenharmony_ci          })
891e41f4b71Sopenharmony_ci          .contentModifier(new MySliderStyle(this.showSlider,this.sliderChangeMode))
892e41f4b71Sopenharmony_ci
893e41f4b71Sopenharmony_ci      }
894e41f4b71Sopenharmony_ci      .width('100%')
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci    }.width('100%')
897e41f4b71Sopenharmony_ci  }
898e41f4b71Sopenharmony_ci}
899e41f4b71Sopenharmony_ci```
900e41f4b71Sopenharmony_ci
901e41f4b71Sopenharmony_ci![slider_3](figures/slider_builder.gif)
902