Skip to content

Behaviour

The behaviour property controls how the slider responds to user interactions. Keywords are configured separated by hyphens.

Behaviour: tap v-model: [30,70]

Syntax

vue
<Slider
    v-model="value"
    :range="{ min: 0, max: 100 }"
    behaviour="tap-drag"
/>

Available keywords

tap

The closest handle jumps to the clicked position on the slider bar.

vue
behaviour="tap"

This is the default value.

drag

Allows dragging the connect bar between two handles. Requires 2 handles and connect: true.

vue
<Slider
    v-model="values"
    :range="{ min: 0, max: 100 }"
    :connect="true"
    behaviour="drag"
/>

drag-fixed

Like drag, but keeps the distance between handles constant when dragging the connect.

vue
behaviour="drag-fixed"

drag-all

Drags all handles when the connect is moved.

vue
behaviour="drag-all"

fixed

Maintains a fixed distance between handles. Moving one causes the other to move proportionally.

vue
behaviour="fixed"

snap

The handle jumps to the clicked position and can be dragged immediately without releasing the mouse.

vue
behaviour="snap"

hover

Fires the hover event when the mouse passes over the slider, reporting the value at that position.

vue
<Slider
    v-model="value"
    :range="{ min: 0, max: 100 }"
    behaviour="hover"
    @hover="onHover"
/>
js
methods: {
    onHover(value) {
        console.log('Hover at:', value);
    }
}

unconstrained

Allows handles to cross each other. The margin and limit properties are not available in this mode.

vue
behaviour="unconstrained"

smooth-steps

Ignores steps during drag and applies them on release.

vue
behaviour="smooth-steps"

invert-connects

Connects are inverted when handles cross each other. Requires unconstrained, connect, and only works with 2 handles.

vue
<Slider
    v-model="values"
    :range="{ min: 0, max: 100 }"
    :connect="true"
    behaviour="unconstrained-invert-connects"
/>

none

Disables everything except basic handle movement.

vue
behaviour="none"

Combinations

Keywords are combined with hyphens:

vue
<!-- Tap + drag connect -->
behaviour="tap-drag"

<!-- Hover + snap -->
behaviour="hover-snap"

<!-- Unconstrained + tap -->
behaviour="unconstrained-tap"

<!-- Tap + drag with fixed distance -->
behaviour="tap-drag-fixed"

Released under the MIT License.