🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

vue-range-multi

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-range-multi

A Vue range / slider component that supports one or more thumb

0.5.0
latest
Source
npm
Version published
Weekly downloads
130
8.33%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Range Multi

npm version npm downloads bundle JSDocs License

Vue Range Multi Logo

A Vue range(slider) component that supports one or more thumb

  • ✨ Support for one or more thumbs.
  • 🔄 Auto-detect the type of model and display the corresponding thumb(s).
  • 🔀 Automatically sort the model values without sorting the DOM.
  • ➕ Ability to add or remove thumbs dynamically.
  • 🚫 Avoid duplicate thumbs by rejecting them.
  • 🍡 Smooth movement or jump movement over the stops.
  • 🎨 Customizable style and theme.
  • 🌓 Supports dark mode.
  • 📍 Render content above or below the thumb(render function / slot).
  • 🏷 Support display marks under the track.

Demo

Demo

Quick Start

  • Install
pnpm add vue-range-multi
  • Use in Vue

in SFC

<script setup lang="ts">
import { ref } from 'vue'
import { Range } from 'vue-range-multi'
import 'vue-range-multi/style.css'

const model = ref<number>(0)
</script>

<template>
  <Range v-model="model" />
</template>

install globally

// main.ts
import { Range } from 'vue-range-multi'
import 'vue-range-multi/style.css'

app.component('MRange', Range)
declare module 'vue' {
  export interface GlobalComponents {
    MRange: typeof import('vue-range-multi')['Range']
  }
}

unplugin-vue-components

import { VueRangeMultiResolver } from 'vue-range-multi'

// and then add `VueRangeMultiResolver()` into resolvers
// type of options
interface VueRangeMultiResolverOptions {
  /**
   * The name of the component. It should always CapitalCase
   *
   * @default 'MRange'
   */
  name?: string
}

Props

[!NOTE] After v0.4, marks's key means value rather than percentage

generic="T = any, U = number | RangeData<T>"

NameTypeDescriptionDefault
v-model:modelValue*U \ U[]Model value. It will automatically detect the type of model and show the corresponding thumb(s)[]
minnumberThe minimum value allowed0
maxnumberThe maximum value allowed100
stepnumberStep1
verticalbooleanDetermines if the range is vertical. Note that it will generate new classes like 'm-range-v-xxx'false
addablebooleanDetermines if new data can be added/deleted. You can specify the data to be added by addData propfalse
addData(value: number) => RangeData<T, U>Data to be added. This will only effect while modelValue is RangeData[]. It will return { value } by defaultundefined
limitnumberthe limit can be addundefined
thumbLimits[number, number]Global limit for all thumbs' movement range. Individual thumb can override this with its own limits propertyundefined
smoothbooleanDetermines if the thumb(s) should only be displayed on the stop points or notfalse
deduplicatebooleanDetermines if the thumb(s) can be duplicatedtrue
rangeHighlightbooleanDetermines if the range between the minimum and maximum values should be highlighted.false
progressRangeProgressCustom track highlight segmentundefined
showStopsboolean | numberDetermines if dots should be displayed on the track. When set to a number, dots will only be displayed if the number of stops is less than the specified value12
size'small' | 'medium' | 'large'Track size'small'
thumbType'circle' | 'square' | 'rect'Thumb type(default 'rect' while size is 'large', otherwise 'small')'circle' | 'rect'
thumbSize'small' | 'medium' | 'large'Thumb size'medium'
renderTop(data: U) => VNodeA render function for displaying content above the thumbundefined
renderTopOnActivebooleanSpecifies whether to render only while the thumb is activefalse
renderBottom(data: U) => VNodeA render function for displaying content below the thumbundefined
renderBottomOnActivebooleanSpecifies whether to render only while the thumb is activefalse
marksRangeMarksShow marks under the trackundefined

Events

NameTypeDescription
change(value: RangeValue<T, U>, thumbValue: U, thumbIndex: number) => voidIt will emit when thumb pointerup (after move the thumb)

slots

NameTypeDescription
top{ data: U }render above the thumb, only effect while renderTop is undefined
bottom{ data: U }render below the thumb, only effect while renderBottom is undefined

types

export type RangeValueType<T> = number | RangeData<T>
export interface RangeData<T, U = RangeValueType<T>> {
  value: number
  data?: T
  disabled?: boolean
  unremovable?: boolean
  limits?: [number, number] // Min and max limits for this specific thumb
  renderTop?: RangeRenderFn<T, U>
  renderBottom?: RangeRenderFn<T, U>
}
export type RangeRenderFn<T, U = RangeValueType<T>> = (data: U) => VNode
export type RangeValue<T, U = RangeValueType<T>> = U | U[]
export type RangeProgress = ([number, number] | {
  range: [number, number]
  style?: CSSProperties
  class?: string
})[]
export type RangeMarks = Record<number, string | {
  label: string
  style?: CSSProperties
  class?: string
}>

theme

If you want to customize the theme, just use CSS variables to override the default theme.

.m-range-theme {
  --c-primary: #409eff; /* primary color */
  --c-fill: #e4e7ed; /* track's fill color */
  --c-fill-stop: #f5f5f5; /* stop's fill color */
  --c-fill-thumb: #fff; /* thumb's fill color */
}

License

MIT License © 2023-PRESENT wiidede

Keywords

vue

FAQs

Package last updated on 27 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts