Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Forms

RangeSlider

A bounded interval control composed from two native range inputs.

Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.

Interactive showcase

Install

Run in your project
bunx --bun @getweini/cli@latest add range-slider

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Vue
<script setup lang="ts">
import { ref } from 'vue'
import RangeSlider from './components/ui/range-slider/RangeSlider.vue'

const price = ref<[number, number]>([20, 80])
</script>

<template>
  <RangeSlider
    v-model="price"
    start-label="Minimum price"
    end-label="Maximum price"
    start-name="minimum"
    end-name="maximum"
    :min-range="10"
  />
</template>

startLabel and endLabel name the two range inputs. minRange prevents the handles from crossing or moving too close together. Set both name props to submit the values with a form. Each 20px thumb grows evenly on hover, keyboard focus, and while pressed, making the active point easier to see without changing the input target. It returns to its resting size on release. Reduced motion removes the transition and size changes.

When to use it

Price interval

Choose a lower and upper bound without crossing thumbs.

Age range

Require a meaningful minimum span between selected endpoints.

More examples

Price filter

Give both native range handles distinct names.

Price filter
<script setup lang="ts">
import { ref } from 'vue'
import RangeSlider from './components/ui/range-slider/RangeSlider.vue'

const price = ref<[number, number]>([20, 80])
</script>
<template>
  <RangeSlider
    v-model="price"
    :min="0"
    :max="100"
    :step="5"
    start-label="Minimum price"
    end-label="Maximum price"
    start-name="minPrice"
    end-name="maxPrice"
  />
</template>

Age bracket

minRange preserves at least a ten-year interval.

Age bracket
<script setup lang="ts">
import { ref } from 'vue'
import RangeSlider from './components/ui/range-slider/RangeSlider.vue'

const ages = ref<[number, number]>([25, 55])
const years = (value: number) => `${value} years`
</script>
<template>
  <RangeSlider
    v-model="ages"
    :min="18"
    :max="80"
    :min-range="10"
    start-label="Minimum age"
    end-label="Maximum age"
    :value-label="years"
  />
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

RangeSlider

Complete API for RangeSlider
NameType or signatureDefaultWhat it does
namepropstring | undefinedNot setName used when this control submits a value with a form.
minpropnumber | undefined0Smallest allowed value.
maxpropnumber | undefined100Largest allowed value.
steppropnumber | undefined1Amount added or removed for each adjustment.
minRangepropnumber | undefined0Smallest allowed distance between the two selected values.
disabledpropboolean | undefinedNot setPrevent interaction and show the disabled state.
sizepropControlSize | undefined"md"Choose the visual size. Medium is the usual default where available.
startLabelpropstringRequiredAccessible name for the start of the range.
endLabelpropstringRequiredAccessible name for the end of the range.
startNamepropstring | undefinedNot setForm field name used for the start of the range.
endNamepropstring | undefinedNot setForm field name used for the end of the range.
formpropstring | undefinedNot setAssociate the control with a form by its ID.
valueLabelprop((value: number) => string) | undefinedNot setAccessible text describing the current value.
modelValuemodelRangeSliderValue | undefined[0, 100]Current value. Use v-model to keep it in sync with your page.
update:modelValueevent[value: RangeSliderValue]—Requests a new model value from the parent.
errorslot{ message: string; messages: string[]; }OptionalContent for the error area of RangeSlider.
startElementexposedHTMLInputElement | null—Access start element from a component template ref.
endElementexposedHTMLInputElement | null—Access end element from a component template ref.
focusexposed() => void | undefined—Move keyboard focus to this control.
Public type definitions
Public types
// packages/frameworks/vue/components/range-slider/types.ts
import type { ControlSize } from '@getweini/vue/types'

export type RangeSliderValue = [number, number]

export interface RangeSliderProps {
  name?: string
  min?: number
  max?: number
  step?: number
  minRange?: number
  disabled?: boolean
  size?: ControlSize
  startLabel: string
  endLabel: string
  startName?: string
  endName?: string
  form?: string
  valueLabel?: (value: number) => string
}


// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
    label: string;
    value: T;
    disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
    /** Popup name when no aria-label or aria-labelledby is supplied. */
    listboxLabel: string;
    empty: string;
    clearSelection: string;
}
export interface ListboxProps<T> {
    options: readonly SelectOption<T>[];
    messages: ListboxMessages;
    id?: string;
    disabled?: boolean;
    required?: boolean;
    invalid?: boolean;
    name?: string;
    form?: string;
    placeholder?: string;
    size?: ControlSize;
    clearable?: boolean;
    gap?: number;
    /** Supply stable equality for object values. Values must be unique. */
    by?: (a: T, b: T) => boolean;
    /** Required for meaningful form submission of object values. */
    serialize?: (value: T) => string;
}


// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
    variant?: Variant;
    size?: Size;
    disabled?: boolean;
    loading?: boolean;
    type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
    as?: 'button' | 'a' | Component;
    asChild?: boolean;
}

Implementation notes

  • The model is a two-number tuple. Set both startName and endName for native form submission.
  • minRange prevents the handles from becoming too close.

Accessibility and localization

  • Each thumb is a separate focusable input. Use different, specific start and end labels.

Source contract and editing guidance