Slider

Demos

Size variants

<template>
<article>
  <veui-slider v-model="value"/>
  <veui-slider
    v-model="value"
    ui="small"
  />
  <veui-slider
    v-model="value"
    ui="tiny"
  />
</article>
</template>

<script>
import { Slider } from 'veui'

export default {
  components: {
    'veui-slider': Slider
  },
  data () {
    return {
      value: 0.5
    }
  }
}
</script>

Read-only/disabled

<template>
<article>
  <veui-slider v-model="value"/>
  <veui-slider
    v-model="value"
    readonly
  />
  <veui-slider
    v-model="value"
    disabled
  />
</article>
</template>

<script>
import { Slider } from 'veui'

export default {
  components: {
    'veui-slider': Slider
  },
  data () {
    return {
      value: 0.5
    }
  }
}
</script>

Stepable

<template>
<article>
  <veui-slider
    v-model="value"
    :min="min"
    :max="max"
    :step="step"
    mark
  />
  <veui-slider
    v-model="value"
    :min="min"
    :max="max"
    :step="step"
  />
</article>
</template>

<script>
import { Slider } from 'veui'

export default {
  components: {
    'veui-slider': Slider
  },
  data () {
    return {
      value: 55,
      min: 0,
      max: 100,
      step: 8
    }
  }
}
</script>

Range

<template>
<article>
  <veui-slider
    v-model="value"
    :min="0"
    :max="100"
  />
</article>
</template>

<script>
import { Slider } from 'veui'

export default {
  components: {
    'veui-slider': Slider
  },
  data () {
    return {
      value: [22, 66]
    }
  }
}
</script>

Secondary bar

<template>
<article>
  <veui-slider
    v-model="videoPlayProgress"
    :secondary-progress="videoBufferProgress"
  />
</article>
</template>

<script>
import { Slider } from 'veui'

export default {
  components: {
    'veui-slider': Slider
  },
  data () {
    return {
      videoPlayProgress: 0.11,
      videoBufferProgress: 0.57
    }
  }
}
</script>

Customization

"hsl(60, 100%, 50%)" , "hsl(120, 100%, 50%)" , "hsl(180, 100%, 50%)" , "hsl(240, 100%, 50%)" , "hsl(300, 100%, 50%)"
<template>
<article>
  <veui-slider
    v-model="value"
    :min="0"
    :max="360"
    :step="1"
    :parse="parseColorHue"
    :format="formatColorHue"
  >
    <div
      slot="track"
      style="width: 100%; height: 20px;"
      :style="{background: colorGradient}"
    />
    <div
      slot="thumb"
      :key="`thumb_${index}`"
      slot-scope="{ index }"
      style="margin-top: 2px"
    >
      <div style="width: 16px; height: 12px">
        <svg
          width="16"
          height="12"
          viewBox="0 0 16 12"
        ><polygon points="8,0 16,12 0,12"/></svg>
      </div>
    </div>
    <template
      slot="tip"
      slot-scope="{ open, activeIndex }"
    >
      <div
        v-show="open"
        class="custom-tip"
        :style="{
          left: `${(activeIndex >= 0 ? parseColorHue(value[activeIndex]) : 0) / 360 * 100}%`,
          backgroundColor: value[activeIndex]
        }"
      />
    </template>
  </veui-slider>
  <div>
    <span
      v-for="(val, index) in value"
      :key="`color-value-${index}`"
    >
      "<span :style="{ color: val }">{{ val }}</span>"
      <span v-if="index < value.length - 1">,</span>
    </span>
  </div>
</article>
</template>

<script></script>

API

Props

NameTypeDefaultDescription
uistring-

Style variants.

ValueDescription
smallSmall size.
tinyTiny size.
value*|Array<*>-

The value of the slider.

By default the type is number and the value should between min and max after parsed by the parse function.

When being the type of Array<number>, multiple thumbs will be rendered corresponding to each value.

When parse and format are specified, values can be of any type, and parse should transform the value to number and format should transform the value to the same type as the value prop. parse and format only need to take care of single values instead of arrays and the component itself will apply transformation on multiple values if necessary.

secondary-progressnumber|Array<number>0Secondary progress value.
minnumber0The minimun value after value is processed by the parse function.
maxnumber1The maximum value after value is processed by the parse function.
stepnumber0The step value after value is processed by the parse function.
markbooleanfalseWhether to display step marks.
parsefunctionval => valThe parse function to transform input value.
formatfunctionval => valThe format function to transform output value.

Slots

NameDescription
trackThe track of the slider. Displays a bar by default.
tip-labelThe tooltip content. Displays the current value or its item by default.
thumb

The thumb(s) of the slider. Displays a round button by default.

NameTypeDescription
indexnumberThe index of current thumb.
focusbooleanWhether current thumb is focused.
hoverbooleanWhether user is pointing current thumb.
draggingbooleanWhether the current thumb is being dragged.
tip

The entire tooltip for each thumb. Displays a Tooltip component with value as its content by default.

NameTypeDescription
targetHTMLElementThe rendered Element for current thumb.
openbooleanWhether there is any active thumb.
active-indexbooleanThe index of the current active thumb.

Events

NameDescription
input

v-model

Triggered after the value changed. The callback parameter type is (value: *), where value is the new value (transformed by the format function).