<BaseSlider /> · A range indicator element.
<template>
<BaseSlider v-model="range" />
</template>
<script setup lang="ts">
const range = ref([62])
</script>
This component is self closing and can be used to create range sliders.
<template>
<BaseSlider />
</template>
This component has props that you can use to modify its visual style.
| Model | Type |
|---|---|
model-value | number[] | nullThe controlled value of the slider. Can be bind as `v-model`. |
| Prop | Type |
|---|---|
variantdefault: "default" | "default" | "primary" | "dark" | "none" |
classesdefault: {} | { track?: string | string[]; range?: string | string[]; thumb?: string | string[]; tooltip?: string | string[]; tooltipArrow?: string | string[]; }Optional classes to pass to the inner components. |
default-valuedefault: - | number[]The value of the slider when initially rendered. Use when you do not need to control the state of the slider. |
disableddefault: - | booleanWhen `true`, prevents the user from interacting with the slider. |
orientationdefault: - | DataOrientationThe orientation of the slider. |
dirdefault: - | DirectionThe reading direction of the combobox when applicable. If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. |
inverteddefault: - | booleanWhether the slider is visually inverted. |
mindefault: - | numberThe minimum value for the range. |
maxdefault: - | numberThe maximum value for the range. |
stepdefault: - | numberThe stepping interval. |
min-steps-between-thumbsdefault: - | numberThe minimum permitted steps between multiple thumbs. |
thumb-alignmentdefault: - | ThumbAlignmentThe alignment of the slider thumb. - `contain`: thumbs will be contained within the bounds of the track. - `overflow`: thumbs will not be bound by the track. No extra offset will be added. |
as-childdefault: - | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
asdefault: - | AsTag | ComponentThe element or component this component should render as. Can be overwritten by `asChild`. |
namedefault: - | stringThe name of the field. Submitted with its owning form as part of a name/value pair. |
requireddefault: - | booleanWhen `true`, indicates that the user must set the value before the owning form can be submitted. |
| Event | Emitted Value Type |
|---|---|
value-commit | [payload: number[]] |
| Slot | Type |
|---|---|
#default | { value: number; } |
Your can override the component default CSS variables in your main.css file.
@theme {
/* Default progress bar variables */
--color-track-default-bg: var(--color-muted-200);
--color-track-default-bg-active: var(--color-muted-500);
--color-track-default-bg-invert: var(--color-white);
--color-track-default-handle-bg: var(--color-white);
--color-track-default-handle-border: var(--color-muted-300);
--color-track-default-handle-ring: var(--color-track-default-bg-active);
/* Dark progress bar variables */
--color-track-dark-bg: var(--color-muted-200);
--color-track-dark-bg-active: var(--color-muted-900);
--color-track-dark-bg-invert: var(--color-white);
--color-track-dark-handle-bg: var(--color-white);
--color-track-dark-handle-border: var(--color-muted-300);
--color-track-dark-handle-ring: var(--color-track-dark-bg-active);
}
Use the variant prop to change the color of the progress bar. Set it to none to remove the default color and apply your own.
<template>
<BaseSlider v-model="range" />
<BaseSlider v-model="range" variant="primary" />
<BaseSlider v-model="range" variant="dark" />
<BaseSlider
v-model="range"
variant="none"
class="text-pink-500"
:classes="{
tooltip: 'bg-pink-100 dark:bg-pink-900 text-pink-900 dark:text-pink-50',
tooltipArrow: 'fill-pink-100 dark:fill-pink-900',
}"
/>
</template>
<script setup lang="ts">
const range = ref(76)
</script>
Use the v-model prop to set the value of the slider. You can also use an array to set multiple values.
<template>
<BaseSlider v-model="range" />
</template>
<script setup lang="ts">
const range = ref([29, 62, 77])
</script>
Use the orientation prop to change the direction of the slider. Set it to vertical to make it vertical.
<template>
<BaseSlider v-model="range" orientation="vertical" />
</template>
<script setup lang="ts">
const range = ref(76)
</script>
Sliders can be controlled by setting the v-model prop or uncontrolled by setting the value prop.
<template>
<BaseSlider
variant="dark"
:default-value="[40]"
:min="10"
:max="60"
:step="10"
/>
<BaseSlider
v-slot="{ value }"
variant="dark"
:default-value="[30, 40]"
:min="10"
:max="60"
:step="2"
:min-steps-between-thumbs="5"
>
{{ value }}%
</BaseSlider>
</template>