Skip to content

Slider

Rules

Basic Example

js
const rule = {
    type:"slider",
    field:"slider",
    title:"Slider",
    value:[0,52],
    props:{
        min: 0,
        max: 100,
        range: true,
    }
}

Props Configuration Examples

Range Selection

js
const rule = {
    type:"slider",
    field:"priceRange",
    title:"Price Range",
    value:[0,100],
    props:{
        min: 0,
        max: 1000,
        range: true,
        step: 10,
    }
}

Show Marks

js
const rule = {
    type:"slider",
    field:"volume",
    title:"Volume",
    value:50,
    props:{
        min: 0,
        max: 100,
        marks: {
            0: 'Mute',
            50: '50%',
            100: 'Max',
        },
    }
}

Show Input Box

js
const rule = {
    type:"slider",
    field:"discount",
    title:"Discount Rate",
    value:0.9,
    props:{
        min: 0,
        max: 1,
        step: 0.01,
        showInput: true,
    }
}

Vertical Slider

js
const rule = {
    type:"slider",
    field:"height",
    title:"Height",
    value:50,
    props:{
        min: 0,
        max: 100,
        direction: "vertical",
    }
}

Events Examples

Handle Slider Changes

js
const rule = {
    type:"slider",
    field:"volume",
    title:"Volume",
    value:50,
    props:{
        min: 0,
        max: 100,
    },
    on: {
        change: (value) => {
            console.log('Slider value changed:', value);
        },
    },
}

Linkage Update Display Value

js
const rule = [
    {
        type:"slider",
        field:"discount",
        title:"Discount Rate",
        value:0.9,
        props:{
            min: 0,
            max: 1,
            step: 0.01,
        },
        inject: true,
        on: {
            change: ($inject, value) => {
                // Display discount percentage
                $inject.api.setValue('discountText', (value * 100).toFixed(0) + '%');
            },
        },
    },
    {
        type:"input",
        field:"discountText",
        title:"Discount",
        props: {
            disabled: true,
        },
    },
]

Complete configuration items: arco-design_Slider

value: Number | Array

Props

ParameterDescriptionTypeDefault
stepStep size for slidingnumber1
minMinimum value of sliding rangenumber0
marksSet displayed labelsRecord<number, string>-
maxMaximum value of sliding rangenumber100
directionDirection of sliderDirection'horizontal'
disabledWhether disabledbooleanfalse
show-ticksWhether to show tick marksbooleanfalse
show-inputWhether to show input boxbooleanfalse
rangeWhether to enable range selectionbooleanfalse

Events

Event NameDescriptionParameters
changeTriggered when value changesvalue: `number

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.