Date & Time Range Picker
Set up the range picker for date & time pair selection. Regardless if you are interested in the start/end date or the actual range, you have several possibilities of rendering a date and time range picker. The controls option supports different values:
datetime- will render a compact date scroller or dropdown with time picker for date & time range selectioncalendar- will render a calendar view for date range selection (explore date ranges)date- will render a date scroller or dropdown for date range selection (explore date ranges)time- will render a time picker for range selection (explore time ranges)timegrid- will render a time grid for range selection (explore time range selection)
Demo
One of the most common ways to represent date range selection is through a calendar with or without a time picker. Learn how to build a date-only picker.
<template>
<MbscDatepicker
select="range"
display="inline"
:controls="['date']"
:touchUi=" "
/>
</template>
Instead of selecting time from a list of values you can show a grid by passing 'timegrid' to the controls option.
<template>
<MbscDatepicker
select="range"
display="inline"
:controls="['calendar', 'timegrid']"
:touchUi=" "
/>
</template>
Passing datetime to the controls option renders a compact date scroller and a time scroller or dropdown with customizable start and end labels.
<template>
<MbscDatepicker
select="range"
display="inline"
:controls="['datetime']"
:touchUi=" "
/>
</template>
Besides rendering it inline, you can link the range to an input that can be a Mobiscroll input or an existing field. Explore more ways to use the picker.
<template>
<MbscDatepicker
select="range"
:controls="['datetime']"
:touchUi=" "
/>
</template>
When using two separate inputs for start and end, you will want to initialize the component on the first input and make sure to pass the references of the two inputs through the startInput and endInput options.
<script setup>
const startInput = ref(null)
const endInput = ref(null)
</script>
<template>
<MbscDatepicker
:controls="['datetime']"
select="range"
:startInput="startInput"
:endInput="endInput"
:touchUi=" "
/>
<MbscInput ref="startInput" label="Start"/>
<MbscInput ref="endInput" label="End"/>
</template>
<script setup>
import { MbscDatepicker, MbscInput, MbscPage, setOptions } from '@mobiscroll/vue'
import { ref } from 'vue'
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
})
const startInput = ref(null)
const endInput = ref(null)
</script>
<template>
<MbscPage>
<MbscDatepicker :controls="['calendar', 'time']" select="range" display="inline" />
<MbscDatepicker :controls="['calendar', 'timegrid']" select="range" display="inline" />
<MbscDatepicker :controls="['datetime']" select="range" display="inline" />
<MbscDatepicker
:controls="['datetime']"
select="range"
label="Range"
inputStyle="outline"
labelStyle="stacked"
placeholder="Please Select..."
/>
<MbscDatepicker
:controls="['calendar, time']"
:startInput="startInput"
:endInput="endInput"
select="range"
/>
<div class="mbsc-grid mbsc-no-padding">
<div class="mbsc-row">
<div class="mbsc-col-6">
<MbscInput
ref="startInput"
label="Start"
inputStyle="outline"
labelStyle="stacked"
placeholder="Please Select..."
/>
</div>
<div class="mbsc-col-6">
<MbscInput
ref="endInput"
label="End"
inputStyle="outline"
labelStyle="stacked"
placeholder="Please Select..."
/>
</div>
</div>
</div>
</MbscPage>
</template>
<script setup lang="ts">
import { MbscDatepicker, MbscInput, MbscPage, setOptions } from '@mobiscroll/vue'
import { ref } from 'vue'
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
})
const startInput = ref<any>(null)
const endInput = ref<any>(null)
</script>
<template>
<MbscPage>
<MbscDatepicker :controls="['calendar', 'time']" select="range" display="inline" />
<MbscDatepicker :controls="['calendar', 'timegrid']" select="range" display="inline" />
<MbscDatepicker :controls="['datetime']" select="range" display="inline" />
<MbscDatepicker
:controls="['datetime']"
select="range"
label="Range"
inputStyle="outline"
labelStyle="stacked"
placeholder="Please Select..."
/>
<MbscDatepicker
:controls="['calendar, time']"
:startInput="startInput"
:endInput="endInput"
select="range"
/>
<div class="mbsc-grid mbsc-no-padding">
<div class="mbsc-row">
<div class="mbsc-col-6">
<MbscInput
ref="startInput"
label="Start"
inputStyle="outline"
labelStyle="stacked"
placeholder="Please Select..."
/>
</div>
<div class="mbsc-col-6">
<MbscInput
ref="endInput"
label="End"
inputStyle="outline"
labelStyle="stacked"
placeholder="Please Select..."
/>
</div>
</div>
</div>
</MbscPage>
</template>