Skip to content

Slider

WxSlider covers one thumb or two. Two is what a shop filter needs — a price band with both ends draggable.

Single
40

Model: 40 — a number, not an array

Range, the shape a shop filter needs
200 — 700

Model: [200,700]

Marks
Disabled

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'

const volume = ref(40)
const price = ref([200, 700])
</script>

<template>
  <wx-slider v-model="volume" show-value />
  <wx-slider v-model="price" range :min="0" :max="1000" :step="50" />
</template>

A single slider keeps a plain number in the model, not a one-element array — that is what a caller stores. With range the model is a pair.

Props

PropTypeDefaultDescription
modelValuenumber | number[]nullValue, or a pair when range
rangebooleanfalseTwo thumbs
minnumber0Lower bound
maxnumber100Upper bound
stepnumber1Stepping interval
minStepsBetweenThumbsnumber0Smallest gap between the thumbs
marksRecord<number, string>Ticks under the track
showValuebooleanfalsePrint the value beside the track
disabledbooleanfalseDisables dragging
size'sm' | 'md' | 'lg''md'Row height
idstringgeneratedOverrides the id the label points at; WxFormItem supplies one
namestringname of the underlying input
ariaLabelstringLabel when there is no visible one

Events: update:modelValue, change.

An empty model starts a single slider at min and a range at [min, max], so the thumbs always have somewhere to be.

Accessibility

Built on Reka UI's slider: each thumb is a role="slider" with its own value, arrow keys step, Home and End jump to the bounds, and Page Up / Page Down move in larger jumps.

Released under the MIT License.