WlSlider

Slider using input type="range" with a filled track up to the selected value.
Components / Inputs v0.1.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

min

Minimum.

max

Maximum.

step

Step.

ariaLabel

aria-label.

startLabel

Accessible label for the range start control.

endLabel

Accessible label for the range end control.

Disables the slider.

Expose a validation error state on the control.

Use two slider handles with a start/end value pair.

Props size, density, ariaValueText, marks, pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Volume: 40%

Value: 50

Range startRange end

Range: 20 – 80

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlSlider } from "legato-ui";
import { ref } from "vue";
const value = ref(40);
const marked = ref(50);
const range = ref<[number, number]>([20, 80]);
const marks = [0, 25, 50, 75, 100];
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlSlider
      v-model="value"
      :min="0"
      :max="100"
      :step="10"
      aria-label="Volume"
      
    /><p class="wl-text-small">{{ "Volume:" }} {{ value }}%</p>
    <WlSlider
      
      v-model="marked"
      :range="false"
      :marks="marks"
      aria-label="Slider with marks"
    />
    <p class="wl-text-small">{{ "Value:" }} {{ marked }}</p>
    <WlSlider
      
      v-model="range"
      range
      :marks="marks"
      aria-label="Range with marks"
    />
    <p class="wl-text-small">{{ "Range:" }} {{ range.join(' – ') }}</p>
  </div>
</template>

Ranges and current value

Two constrained ranges with different steps, text outputs, disabling and reset.

Range, step and current value

40%From 0 to 100, step 5.
20 minutesFrom 10 to 50, step 10.

Arrow keys, Home and End control the native range. The current value appears as a number beside it.

Unavailable slider

60%

Volume: 40%. Interval: 20 minutes.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlField, WlSlider } from "legato-ui";
import { ref } from "vue";
const volume = ref(40);
const interval = ref(20);
</script>

<template>
  <div class="wl-stack" data-space="xl" data-input-example="WlSlider">
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "Range, step and current value" }}</h3>
      <WlField
        id="docs-slider-volume"
        v-slot="{ id, ariaDescribedby }"
        label="Volume"
        hint="From 0 to 100, step 5."
      >
        <WlSlider
          :id="id"
          v-model="volume"
          :min="0"
          :max="100"
          :step="5"
          aria-label="Volume"
          :aria-describedby="ariaDescribedby"
        />
        <output :for="id" class="wl-text-small" aria-label="Volume">{{ volume }}%</output>
      </WlField>
      <WlField
        id="docs-slider-interval"
        v-slot="{ id, ariaDescribedby }"
        label="Interval, minutes"
        hint="From 10 to 50, step 10."
      >
        <WlSlider
          :id="id"
          v-model="interval"
          :min="10"
          :max="50"
          :step="10"
          aria-label="Interval"
          :aria-describedby="ariaDescribedby"
        />
        <output :for="id" class="wl-text-small" aria-label="Interval">{{
          interval
        }} {{ "minutes" }}</output>
      </WlField>
      <p class="wl-text-small wl-text-muted">{{ "Arrow keys, Home and End control the native range. The current value appears as a number beside it." }}</p>
    </section>
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "Unavailable slider" }}</h3>
      <WlField id="docs-slider-disabled" v-slot="{ id }" label="Fixed level"><WlSlider
        :id="id"
        :model-value="60"
        disabled
        aria-label="Fixed level"
      /><output :for="id" class="wl-text-small" aria-label="Fixed level">60%</output></WlField>
      <WlButton size="sm" @click="volume = 40; interval = 20">{{ "Reset ranges" }}</WlButton>
      <p class="wl-text-small" role="status">{{
        "Volume:"
      }} {{
        volume
      }}{{
        "%. Interval:"
      }} {{
        interval
      }} {{
        "minutes."
      }}</p>
    </section>
  </div>
</template>