Skip to content

Slider API Reference

Props

PropTypeDefaultDescription
modelValueNumber0v-model binding value
valueNumber0Alternative to modelValue
disabledBooleanfalseDisables the slider
readonlyBooleanfalseMakes the slider read-only
stepNumber0.1Step increment/decrement value
variantString'default'Visual variant class (e.g. 'default', 'success')
labelString''Label text for the slider
minNumber0Minimum value of the slider
maxNumber100Maximum value of the slider
thumbLabelString/BooleanfalseControls thumb label visibility. Options: 'always', true (show on drag/focus), false
thumbLabelClassesArray[]Additional CSS classes for the thumb label
labelClassesArray[]Additional CSS classes for the main label

Events

EventPayloadDescription
update:modelValueNumberEmitted when the value changes
changeNumberEmitted when the value changes with additional context

Slots

SlotPropsDescription
label-Custom label content

Accessibility

The slider component implements the following ARIA attributes:

  • role="slider"
  • aria-valuemin: Set to the min prop value
  • aria-valuemax: Set to the max prop value
  • aria-valuenow: Current value of the slider
  • aria-disabled: Set based on the disabled prop
  • aria-readonly: Set based on the readonly prop

Keyboard Navigation

The slider supports the following keyboard interactions:

  • ArrowRight: Increase value by step amount
  • ArrowLeft: Decrease value by step amount

Example Usage

Basic Usage

vue
<template>
  <OSlider
    v-model="value"
    label="Volume"
    :min="0"
    :max="100"
    :step="1"
    variant="default"
  />
</template>

<script setup>
import { ref } from "vue";
import { OSlider } from "your-component-library";

const value = ref(50);
</script>

With Custom Label

vue
<template>
  <OSlider v-model="value" :min="0" :max="100">
    <template #label>
      <div class="custom-label">
        <span>Custom Label</span>
        <span class="value">{{ value }}</span>
      </div>
    </template>
  </OSlider>
</template>

<script setup>
import { ref } from "vue";
import { OSlider } from "your-component-library";

const value = ref(50);
</script>

<style>
.custom-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.value {
  color: #666;
}
</style>

Disabled State

vue
<template>
  <OSlider v-model="value" label="Disabled Slider" :disabled="true" />
</template>

<script setup>
import { ref } from "vue";
import { OSlider } from "your-component-library";

const value = ref(50);
</script>

Variant and Thumb Label

vue
<template>
  <OSlider
    v-model="value"
    label="Success Variant"
    variant="success"
    thumbLabel="always"
    :min="0"
    :max="100"
  />
</template>

<script setup>
import { ref } from "vue";
import { OSlider } from "your-component-library";

const value = ref(50);
</script>