Gathering detailed insights and metrics for vue-double-range-input
Gathering detailed insights and metrics for vue-double-range-input
Gathering detailed insights and metrics for vue-double-range-input
Gathering detailed insights and metrics for vue-double-range-input
npm install vue-double-range-input
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
6
Double 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:
1npm i vue-double-range-input
Then You should Import component's style:
1import 'vue-double-range-input/dist/style.css';
Now you can import package:
1import VueDoubleRangeInput from 'vue-double-range-input';
This is a simple version of component with minimum props that needed:
1<VueDoubleRangeInput :min="min" 2 :max="max" 3 v-model:minValue="minValue" 4 v-model:maxValue="maxValue" />
If you want to change the text of numbers, you can do it like below:
1<VueDoubleRangeInput :min="min" 2 :max="max" 3 v-model:minValue="minValue" 4 v-model:maxValue="maxValue"> 5 <!-- Do not change minValueRef and maxValueRef spelling --> 6 <template #from="{ minValueRef }"> 7 از: {{ (Number(minValueRef)).toLocaleString('fa-IR') }} 8 </template> 9 <template #to="{ maxValueRef }"> 10 تا: {{ (Number(maxValueRef)).toLocaleString('fa-IR') }} 11 </template> 12</VueDoubleRangeInput>
If you only want to get min and max value and show it where you want, you can do it like below:
1const min = ref(0); 2const max = ref(100); 3const minValue = ref(25); 4const maxValue = ref(75); 5 6const outMinValueRef = ref(0); 7const outMaxValueRef = ref(0); 8 9function outMinValue(val) { 10 outMinValueRef.value = val; 11} 12function outMaxValue(val) { 13 outMaxValueRef.value = val; 14}
1<div> 2 {{ outMinValueRef }} 3 <br /> 4 {{ outMaxValueRef }} 5</div> 6<VueDoubleRangeInput :min="min" 7 :max="max" 8 v-model:minValue="minValue" 9 v-model:maxValue="maxValue"> 10 <template #from="{ minValueRef }"> 11 {{ outMinValue(minValueRef) }} 12 </template> 13 <template #to="{ maxValueRef }"> 14 {{ outMaxValue(maxValueRef) }} 15 </template> 16</VueDoubleRangeInput>
Use :value
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.
1<div> 2 <input type="text" name="min_value" id="min_value" 3 :value="minValue" 4 @change="minValue = $event.target.value"> 5 <input type="text" name="max_value" id="max_value" 6 :value="maxValue" 7 @change="maxValue = $event.target.value"> 8</div>
This one has everything that you can do on this component:
1<div> 2 <input type="text" name="min_value" id="min_value" 3 :value="minValue" 4 @change="minValue = $event.target.value"> 5 <input type="text" name="max_value" id="max_value" 6 :value="maxValue" 7 @change="maxValue = $event.target.value"> 8</div> 9<VueDoubleRangeInput dir="rtl" 10 step="5" 11 color="#2497E3" 12 track-color="rgba(100,100,100,0.5)" 13 track-radius="5px" 14 track-height="10px" 15 handler-color="#2497E3" 16 handler-radius="5px" 17 handler-width="24px" 18 handler-height="24px" 19 :push-on-touch="false" 20 :show-numbers="true" 21 :min="min" 22 :max="max" 23 v-model:minValue="minValue" 24 v-model:maxValue="maxValue"> 25 <template #from="{ minValueRef }"> 26 از: {{ (Number(minValueRef)).toLocaleString('fa-IR') }} 27 </template> 28 <template #to="{ maxValueRef }"> 29 تا: {{ (Number(maxValueRef)).toLocaleString('fa-IR') }} 30 </template> 31</VueDoubleRangeInput>
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. |
--------------------------- | ---------- | -------- |
No vulnerabilities found.
No security vulnerabilities found.