Double range input for vue 3 with min and max value that help you select two value with one input
npm install vue-double-range-inputDouble range input for vue 3 with min and max value that help you select two value with one input.
One of important usage is in shops for filtering between min and max price.
Run this code to install this package:
``sh`
npm i vue-double-range-input
Then You should Import component's style:
`js`
import 'vue-double-range-input/dist/style.css';
Now you can import package:
`js`
import VueDoubleRangeInput from 'vue-double-range-input';
This is a simple version of component with minimum props that needed:
`html`
v-model:minValue="minValue"
v-model:maxValue="maxValue" />
___$3
If you want to change the text of numbers, you can do it like below:
`html`
v-model:minValue="minValue"
v-model:maxValue="maxValue">
از: {{ (Number(minValueRef)).toLocaleString('fa-IR') }}
تا: {{ (Number(maxValueRef)).toLocaleString('fa-IR') }}
`
---$3
If you only want to get min and max value and show it where you want, you can do it like below:javascript
const min = ref(0);
const max = ref(100);
const minValue = ref(25);
const maxValue = ref(75);
const outMinValueRef = ref(0);
const outMaxValueRef = ref(0);
function outMinValue(val) {
outMinValueRef.value = val;
}
function outMaxValue(val) {
outMaxValueRef.value = val;
}
``html`
{{ outMinValueRef }}
{{ outMaxValueRef }}
v-model:minValue="minValue"
v-model:maxValue="maxValue">
{{ outMinValue(minValueRef) }}
{{ outMaxValue(maxValueRef) }}
:value
---$3
Use and @change if you want to change values in an input.
> Note: If you want to change component values from outside, its better to use :value and @change like below. Otherwise you may see some weird issues.
`html`
:value="minValue"
@change="minValue = $event.target.value">
:value="maxValue"
@change="maxValue = $event.target.value">`
---$3
This one has everything that you can do on this component:html``
:value="minValue"
@change="minValue = $event.target.value">
:value="maxValue"
@change="maxValue = $event.target.value">
color="#2497E3"
track-color="rgba(100,100,100,0.5)"
track-radius="5px"
track-height="10px"
handler-color="#2497E3"
handler-radius="5px"
handler-width="24px"
handler-height="24px"
:push-on-touch="false"
:show-numbers="true"
:min="min"
:max="max"
v-model:minValue="minValue"
v-model:maxValue="maxValue">
از: {{ (Number(minValueRef)).toLocaleString('fa-IR') }}
تا: {{ (Number(maxValueRef)).toLocaleString('fa-IR') }}
|prop |default |description|
|----------------|----------------| --- |
|dir |ltr | don't use it if your want to be ltr or just put ltr in it.|
|step |null |just like step in normal range input.|
|color |#2497E3 |color of line between two value (accept all css color selector).|
|track-color |#cccccc |set color of full track in behind (accept all css color selector).|
|track-height |9px |set height for track.|
|track-radius |9999px |set border-radius for track.|
|handler-color |#2497E3 |set color of circle handlers of input range (accept all css color selector).|
|handler-radius |9999px |set border-radius for handlers.|
|handler-width |24px |set width for handlers.|
|handler-height |24px |set height for handlers.|
|show-numbers |true |set it to false if you want to hide "from" and "to" numbers.|
|push-on-touch |true |false: min value cannot go above max value and max value cannot go below min value.
true: if min value become greater than max value, max value automatically set to min value and vise versa.|
|min |0 |same as min in normal range input.|
|max |100 |same as max in normal range input.|
|v-model:minValue|25 |same as value in normal range input but for min.|
|v-model:maxValue|75 |same as value in normal range input but for max.|
|---------------------------|----------|--------|