openharmony 鸿蒙 js-components-basic-slider

2025-06-12 浏览 (1)

slider

NOTE

This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.

The <slider> component is used to quickly adjust settings, such as the volume and brightness.

Child Components

Not supported

Attributes

In addition to the universal attributes, the following attributes are supported.

NameTypeDefault ValueMandatoryDescription
minnumber0NoMinimum value of the slider.
maxnumber100NoMaximum value of the slider.
stepnumber1NoStep of each slide.
valuenumber0NoInitial value of the slider.
mode5+stringoutsetNoSlider style. Available values are as follows:
- outset: The slider is on the slider track.
- inset: The slider is in the slider track.
showsteps5+booleanfalseNoWhether to display slider scales.
showtips5+booleanfalseNoWhether a tooltip is displayed to show the percentage value on the slider.

Styles

In addition to the universal styles, the following styles are supported.

NameTypeDefault ValueMandatoryDescription
color<color>#19000000NoBackground color of the slider.
selected-color<color>#ff007dffNoSelected color of the slider.
block-color<color>#ffffffNoSlider color.

Events

In addition to the universal events, the following events are supported.

NameParameterDescription
changeChangeEventTriggered when the value changes.

Table 1 ChangeEvent

AttributeTypeDescription
value5+numberCurrent value of the slider.
mode5+stringType of the change event. Available values are as follows:
- start: The value starts to change.
- move: The value is changing with users' dragging.
- end: The value stops changing.
- click: The value changes upon a touch on the slider.

Example

<!-- xxx.hml -->
<div class="container">
    <slider min="0" max="100" value="{{ value }}" mode="outset" showtips="true"></slider>
    <slider class="" min="0" max="100" value="{{ value }}" step="20" mode="inset"  showtips="true"></slider>
    <slider class="" min="0" max="100" value="{{ value }}" showsteps="true" step="20" mode="inset"  showtips="false"></slider>
</div>
/* xxx.css */
.container {
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
slider{
    margin-top: 100px;
}

slider

你可能感兴趣的鸿蒙文章

harmony 鸿蒙JavaScript-compatible Web-like Development Paradigm (ArkUI.Full)

harmony 鸿蒙Data Type Attributes

harmony 鸿蒙button

harmony 鸿蒙chart

harmony 鸿蒙divider

harmony 鸿蒙image-animator

harmony 鸿蒙image

harmony 鸿蒙input

harmony 鸿蒙label

harmony 鸿蒙marquee

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/qw44hr