---
title: "Vue Range Event Date Selection Example | Mobiscroll"
component: "Range"
framework: "Vue"
library_version: "6.2.0"
url: "https://demo.mobiscroll.com/vue/range/adding-event-start-end"
---

# Event Date Selection - Vue Range demo

Pick start and end dates for events with the Vue date range picker — switch between date-only and date and time entry with an all-day toggle. For Vue and Nuxt.

- [Live demo](https://demo.mobiscroll.com/vue/range/adding-event-start-end)
- [View SFC JS code on GitHub](https://github.com/acidb/mobiscroll-demos-vue/tree/main/src/demos/datepicker/range/adding-event-start-end)
- [View SFC TS code on GitHub](https://github.com/acidb/mobiscroll-demos-vue-ts/tree/main/src/demos/datepicker/range/adding-event-start-end)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/range/adding-event-start-end.md), [jQuery](https://demo.mobiscroll.com/jquery/range/adding-event-start-end.md), [Angular](https://demo.mobiscroll.com/angular/range/adding-event-start-end.md), [React](https://demo.mobiscroll.com/react/range/adding-event-start-end.md)

## Description

Use the range picker for a new event creation. Let people pick start and end dates when adding events.

Dynamically switch between date only and date-time entry based on an "all-day" switch by changing the `controls` to `'date'` or `'datetime'`.

**Interested in an event calendar solution?** [Check out the event calendar →](https://demo.mobiscroll.com/vue/eventcalendar)

## What this demo shows

- Shows a mobile form for creating and editing calendar events with a date range picker.
- **Event details** Fields for the title, location, all-day status, start and end date and time, availability, and notes.
- **Initial values** The editor can open with predefined start and end values or empty date fields for the user to complete.
- **All-day events** A toggle switches between timed and all-day events, changing the picker controls from date and time to date only.
- **Availability** A segmented control sets the event status to busy or free.
- **Date and time selection** Selecting the start or end field opens a wheel-style picker optimized for touch interaction.
- **Range editing** The start and end values can be edited independently while both remain visible in the picker for context.
- **Picker actions** Cancel discards date and time changes, while Set confirms them.

## Best for

- **Calendar event creation** Mobile forms for adding or updating calendar events.
- **Appointment scheduling** Editors that collect event details, date ranges, and availability.
- **Meeting editors** Workflows for switching between timed and all-day meetings.

## Tutorial

```vue
<script setup>
const allDay = ref(false)
const showAs = ref('busy')
const myControls = ref(['datetime'])
const startInput = ref(null)
const endInput = ref(null)

function allDayChange() {
  myControls.value = allDay.value ? ['date'] : ['datetime']
}
</script>

<template>
  <MbscInput label="Title" placeholder="Name of the event" />
  <MbscInput label="Location" placeholder="Where will it be?" />
  <MbscSwitch label="All day" v-model="allDay" @change="allDayChange" />
  <MbscDatepicker
    select="range"
    :controls="myControls"
    :startInput="startInput"
    :endInput="endInput"
  />
  <MbscInput ref="startInput" label="Start" placeholder="Event start" />
  <MbscInput ref="endInput" label="End " placeholder="Event end" />
  <MbscSegmentedGroup v-model="showAs">
    <MbscSegmented value="busy">Show as busy</MbscSegmented>
    <MbscSegmented value="free">Show as free</MbscSegmented>
  </MbscSegmentedGroup>
  <MbscTextarea label="Notes" placeholder="Enter notes, URL, comments" />
</template>
```

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/vue/datepicker/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/vue/datepicker/api#opt-themeVariant) - option
- [`change`](https://mobiscroll.com/docs/vue/forms/switch#event-onChange) - event
- [`select`](https://mobiscroll.com/docs/vue/datepicker/api#opt-select) - option
- [`controls`](https://mobiscroll.com/docs/vue/datepicker/api#opt-controls) - option
- [`startInput`](https://mobiscroll.com/docs/vue/datepicker/api#opt-startInput) - option
- [`endInput`](https://mobiscroll.com/docs/vue/datepicker/api#opt-endInput) - option

## Code

### SFC JS

```vue
<script setup>
import {
  MbscDatepicker,
  MbscInput,
  MbscPage,
  MbscSegmented,
  MbscSegmentedGroup,
  MbscSwitch,
  MbscTextarea,
  setOptions
} from '@mobiscroll/vue'
import { ref } from 'vue'

setOptions({
  theme: 'ios',
  themeVariant: 'light'
})

const allDay = ref(false)
const showAs = ref('busy')
const myControls = ref(['datetime'])
const startInput = ref(null)
const endInput = ref(null)

function allDayChange() {
  myControls.value = allDay.value ? ['date'] : ['datetime']
}
</script>

<template>
  <MbscPage>
    <MbscInput label="Title" placeholder="Name of the event" />
    <MbscInput label="Location" placeholder="Where will it be?" />
    <MbscSwitch label="All day" v-model="allDay" @change="allDayChange" />
    <MbscDatepicker
      select="range"
      :controls="myControls"
      :startInput="startInput"
      :endInput="endInput"
    />
    <MbscInput ref="startInput" label="Start" placeholder="Event start" />
    <MbscInput ref="endInput" label="End " placeholder="Event end" />
    <MbscSegmentedGroup v-model="showAs">
      <MbscSegmented value="busy">Show as busy</MbscSegmented>
      <MbscSegmented value="free">Show as free</MbscSegmented>
    </MbscSegmentedGroup>
    <MbscTextarea label="Notes" placeholder="Enter notes, URL, comments" />
  </MbscPage>
</template>
```

### SFC TS

```vue
<script setup lang="ts">
import {
  MbscDatepicker,
  MbscInput,
  MbscPage,
  MbscSegmented,
  MbscSegmentedGroup,
  MbscSwitch,
  MbscTextarea,
  setOptions
} from '@mobiscroll/vue'
import { ref } from 'vue'

setOptions({
  theme: 'ios',
  themeVariant: 'light'
})

const allDay = ref<boolean>(false)
const showAs = ref<string>('busy')
const myControls = ref<any>(['datetime'])
const startInput = ref<any>(null)
const endInput = ref<any>(null)

function allDayChange() {
  myControls.value = allDay.value ? ['date'] : ['datetime']
}
</script>

<template>
  <MbscPage>
    <MbscInput label="Title" placeholder="Name of the event" />
    <MbscInput label="Location" placeholder="Where will it be?" />
    <MbscSwitch label="All day" v-model="allDay" @change="allDayChange" />
    <MbscDatepicker
      select="range"
      :controls="myControls"
      :startInput="startInput"
      :endInput="endInput"
    />
    <MbscInput ref="startInput" label="Start" placeholder="Event start" />
    <MbscInput ref="endInput" label="End " placeholder="Event end" />
    <MbscSegmentedGroup v-model="showAs">
      <MbscSegmented value="busy">Show as busy</MbscSegmented>
      <MbscSegmented value="free">Show as free</MbscSegmented>
    </MbscSegmentedGroup>
    <MbscTextarea label="Notes" placeholder="Enter notes, URL, comments" />
  </MbscPage>
</template>
```

## Implementation notes

- Set `select: 'range'` with `controls: ['datetime']` (or `['date']` for all-day) on a single `Datepicker` instance to collect a start and end date/time pair.
- Bind the picker to two separate fields via `startInput`/`endInput` instead of a single value input: React/Vue pass input element refs, Angular passes template reference variables through `[startInput]`/`[endInput]`, and JS/jQuery pass CSS selector strings (e.g. `'#start'`, `'#end'`).
- Toggling an "all-day" control switches `controls` between `['date']` and `['datetime']` at runtime: JS/jQuery call `.setOptions({ controls: [control] })` on the picker instance; React recomputes the `controls` prop from state; Angular/Vue update the bound `controls` array reactively.
- The picker only manages the date/time range itself - title, location, busy/free, and notes are ordinary form fields with no picker-option equivalent.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-vue.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config vue
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config vue --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/vue/getting-started/installation

## Related demos

- Previous: [Rental Availability](https://demo.mobiscroll.com/vue/range/book-rental-months-ahead.md) - Build a rental availability calendar with the Vue date range picker — multi-month view with seasonal pricing display and booking validation.
