JGuang

Slider

Slider · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Slider

Swipe input showing current value and selectable range.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Swipe input showing current value and selectable range.

When to Use

When the user needs to select within the numerical interval/custom interval, it can be a continuous or discrete value.

Demos

Slider

Props

NameDescriptionTypeDefault
defaultValueDefault valuenumber | [number, number]range ? [0, 0] : 0
disabledWhether disabledbooleanfalse
iconThe icon of sliderReactNode-
marksTick marks{ [key: number]: React.ReactNode }-
maxMax valuenumber100
minMin valuenumber0
onAfterChangeConsistent with the trigger timing of touchend, pass the current value as a parameter(value: number | [number, number]) => void-
onChangeTriggered when the slider is dragged, and the current dragged value is passed in as a parameter(value: number | [number, number]) => void-
popoverWhether to display the popover when dragging. Support passing in function to customize the rendering content.boolean | ((value: number) => ReactNode)false
residentPopoverWhether the popover is permanently displayed , this attribute takes effect when popover existsboolean false
rangeWhether it is a double slidersbooleanfalse
stepStep distance, the value must be greater than 0, and (max-min) can be divisible by step. When marks is not null, the configuration of step is invalidnumber1
ticksWhether to display the scalebooleanfalse
valueCurrent valuenumber | [number, number]-

CSS Variables

NameDescriptionDefault
--fill-colorfilled colorvar(--adm-color-primary)