Trên trang này

Slider

Ví dụ trực tiếp của Slider, kèm đúng file Vue hiển thị từng ví dụ.

Mỗi ví dụ là một file Vue hoàn chỉnh. Chép vào ứng dụng đã cài registry, hoặc mở trong StackBlitz.

Một giá trị

Hiện giá trị cạnh nhãn.

Số đơn mỗi lượt đồng bộ200
SliderBasic.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Slider } from '@/components/ui/slider'

const batchSize = ref([200])
</script>

<template>
  <div class="grid w-full max-w-80 gap-(--bh-space-150)">
    <div class="flex items-center justify-between">
      <span class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">Số đơn mỗi lượt đồng bộ</span>
      <output class="text-(--bh-color-text) [font:var(--bh-font-body-default)]">{{ batchSize[0] }}</output>
    </div>
    <Slider v-model="batchSize" :min="50" :max="500" :step="50" :thumb-labels="['Số đơn mỗi lượt đồng bộ']" />
  </div>
</template>

Một khoảng

Hai núm chọn giá trị nhỏ nhất và lớn nhất.

Giá200.000 ₫ đến 800.000 ₫
SliderRange.vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { Slider } from '@/components/ui/slider'

const price = ref([200000, 800000])
const usd = new Intl.NumberFormat('vi-VN', { style: 'currency', currency: 'VND' })
const label = computed(() => `${usd.format(price.value[0] ?? 0)} đến ${usd.format(price.value[1] ?? 0)}`)
</script>

<template>
  <div class="grid w-full max-w-80 gap-(--bh-space-150)">
    <div class="flex items-center justify-between">
      <span class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">Giá</span>
      <output class="text-(--bh-color-text) [font:var(--bh-font-body-default)]">{{ label }}</output>
    </div>
    <Slider v-model="price" :min="0" :max="2000000" :step="50000" :min-steps-between-thumbs="1" :thumb-labels="['Giá thấp nhất', 'Giá cao nhất']" />
  </div>
</template>

Vô hiệu

Rãnh và khoảng dùng màu vô hiệu.

Tồn kho dự phòng10%

Hãy bật đồng bộ tồn kho để đặt mức dự phòng.

SliderDisabled.vue
<script setup lang="ts">
import { Slider } from '@/components/ui/slider'
</script>

<template>
  <div class="grid w-full max-w-80 gap-(--bh-space-150)">
    <div class="flex items-center justify-between">
      <span class="text-(--bh-color-text-disabled) [font:var(--bh-font-label-default)]">Tồn kho dự phòng</span>
      <output class="text-(--bh-color-text-disabled) [font:var(--bh-font-body-default)]">10%</output>
    </div>
    <Slider :default-value="[10]" :max="50" disabled :thumb-labels="['Tồn kho dự phòng']" />
    <p class="m-0 text-(--bh-color-text-subtle) [font:var(--bh-font-body-small)]">Hãy bật đồng bộ tồn kho để đặt mức dự phòng.</p>
  </div>
</template>