Vue Monthly Picker Component

0.2.8 · maintenance · verified Sun Apr 19

Vue Monthly Picker (current version 0.2.8) is a specialized Vue 2 component designed for selecting a specific month and year. It relies on Moment.js for all underlying date manipulation and formatting, specifically requiring Moment.js version ^2.18.1. The package maintains a slow and sporadic release cadence, with recent updates focusing on minor feature enhancements like `clearOption`, `alignment`, and `selectedBackgroundColor` props. Its core functionality offers a simple, dedicated user interface for month-only selection, differentiating it from full date pickers. Key features include customizable month labels, min/max date constraints, and flexible display formatting. This component is suitable for projects firmly established on Vue 2 and Moment.js, but users should be aware of the legacy status of its core dependencies.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to register and use `vue-monthly-picker` globally, binding a Moment.js object with `v-model` and setting min/max selectable dates.

import Vue from 'vue';
import VueMonthlyPicker from 'vue-monthly-picker';
import moment from 'moment';

Vue.component('my-monthly-picker', VueMonthlyPicker);

new Vue({
  el: '#app',
  data() {
    return {
      selectedMonth: moment(), // Initialize with a moment object
      minDate: moment().subtract(1, 'year'),
      maxDate: moment().add(1, 'year')
    }
  },
  template: `
    <div id="app">
      <p>Selected Month: {{ selectedMonth ? selectedMonth.format('YYYY-MM') : 'None' }}</p>
      <my-monthly-picker 
        v-model="selectedMonth"
        :min="minDate"
        :max="maxDate"
        placeHolder="Select a month..."
        :clearOption="true"
        dateFormat="MMMM YYYY"
      />
      <p>Choose a month from the picker above.</p>
    </div>
  `
});

view raw JSON →