Shards Vue

Documentation

    Datepickers

    Datepickers in Shards Vue are wrappers over the vuejs-datepicker component. You can learn more about the component in the official component's GitHub repository, or follow the short guide below for an overview of how to use datepickers in Shards Vue.

    Basic Example

    Creating a datepicker can be easily achieved using the <d-datepicker> component.

    
    <template>
        <div>
            <div>Opened: <span :class="[opened ? 'text-success' : 'text-danger']">{{ opened }}</span></div>
            <div>📅 Date: <span>{{ date }}</span></div>
            <d-datepicker
                v-model="date"
                @opened="handleOpened"
                @closed="handleClosed"
                typeable />
        </div>
    </template>
    
    <script>
    export default {
      data() {
        return {
            opened: false,
            date: new Date(2018, 8, 23)
        }
      },
      methods: {
          handleOpened() {
              this.opened = true
          },
          handleClosed() {
              this.opened = false
          }
      }
    }
    </script>
    
    <!-- datepicker-1.vue -->
    

    Disabled Dates

    There are multiple ways that you can follow in order to display disabled dates.

    
    <template>
        <div>
            <div>📅 Date: <span>{{ date }}</span></div>
            <d-datepicker
                v-model="date"
                :disabled-dates="disabledDates"
                typeable />
        </div>
    </template>
    
    <script>
    export default {
      data() {
        return {
            date: new Date(2018, 8, 23),
            disabledDates: {
                // Disable all the dates up to specific date.
                to: new Date(2016, 0, 5),
    
                // Disable all dates after specific date.
                from: new Date(2016, 0, 26),
    
                // Disable only Saturdays and Sundays.
                days: [6, 0],
    
                // Disable 29th, 30th and 31st of each month.
                daysOfMonth: [29, 30, 31],
                
                // Disable an array of dates.
                dates: [
                    new Date(2016, 9, 16),
                    new Date(2016, 9, 17),
                    new Date(2016, 9, 18)
                ],
                
                // Disable dates in given ranges (exclusive).
                ranges: [{
                    from: new Date(2016, 11, 25),
                    to: new Date(2016, 11, 30)
                }, {
                    from: new Date(2017, 1, 12),
                    to: new Date(2017, 2, 25)
                }],
    
                /**
                 * You can also use a custom predictor function that returns true if
                 * the date is disabled or false if it's not. You can use this callback
                 * validator to provide your own date checking logic in case the options
                 * above are not sufficient for your own use case.
                 */
                customPredictor: function(date) {
                    // Disables the date if it is a multiple of 5.
                    if(date.getDate() % 5 == 0){
                        return true
                    }
                }
            }
        }
      }
    }
    </script>
    
    <!-- datepicker-2.vue -->
    

    Highlighted Dates

    
    <template>
        <div>
            <div>📅 Date: <span>{{ date }}</span></div>
            <d-datepicker
                v-model="date"
                :highlighted="highlightedDates"
                typeable />
        </div>
    </template>
    
    <script>
    export default {
      data() {
        return {
            date: new Date(2018, 8, 23),
            highlightedDates: {
                // Highlight all dates up to specific date.
                to: new Date(2016, 0, 5),
    
                // Highlight all dates after specific date.
                from: new Date(2016, 0, 26),
    
                // Highlight Saturdays and Sundays.
                days: [6, 0],
    
                // Highlight 15th, 20th and 31st of each month.
                daysOfMonth: [15, 20, 31],
    
                // Highlight an array of dates.
                dates: [ 
                    new Date(2016, 9, 16),
                    new Date(2016, 9, 17),
                    new Date(2016, 9, 18)
                ],
    
                /**
                 * You can also use a custom predictor function that returns true if
                 * the date is highlighted or false if it's not. You can use this callback
                 * validator to provide your own date checking logic in case the options
                 * above are not sufficient for your own use case.
                 */
                customPredictor: function(date) {
                // Highlights the date if it is a multiple of 4.
                    if(date.getDate() % 4 == 0){
                        return true
                    }
                },
                
                // Highlight disabled dates
                includeDisabled: true
            }
        }
      }
    }
    </script>
    
    <!-- datepicker-3.vue -->
    

    Props

    PropDescriptionTypeDefaultRequired
    :valueThe datepicker's value.UndefinedFalse
    :nameThe name.StringnullFalse
    :idThe component's ID.StringnullFalse
    :formatThe date format.String | Func"dd MMM yyyy"False
    :languageThe language.ObjectFalse
    :open-dateIf set, the datepicker will open on this date.UndefinedFalse
    :day-cell-contentFunction used to render custom content inside the day cell.FuncFalse
    :full-month-nameWhether to show the full month name, or not.BooleanFalse
    :disabled-datesConfigure disabled dates.ObjectFalse
    :highlightedHighlight dates.ObjectFalse
    :placeholderThe placeholder.StringFalse
    :inlineShow the datepicker always open.BooleanFalse
    :calendar-classThe CSS class applied to the calendar element.String | Object | ArrayFalse
    :input-classThe CSS Class applied to the input element.String | Object | Array"form-control"False
    :wrapper-classThe CSS class applied to the wrapper element.String | Object | ArrayFalse
    :monday-firstWhether Monday is the first day, or not.BooleanFalse
    :clear-buttonDisplay a button for clearing the dates.BooleanFalse
    :clear-button-iconUse an icon for the clear button.StringFalse
    :calendar-buttonDislay a calendar button.BooleanFalse
    :calendar-button-iconThe calendar button's icon.StringFalse
    :calendar-button-icon-contentThe calendar button's icon content.StringFalse
    :initial-viewIf set, the datepicker is opened on that specific view.StringFalse
    :disabledThe disabled state.BooleanFalse
    :requiredThe required state.BooleanFalse
    :typeableWhether to allow users to type the date, or not.BooleanFalse
    :use-utcUse UTC for time calculations.BooleanFalse
    :minimum-viewIf set, the lower-level views will not be shown.String"day"False
    :maximum-viewIf set, the higher-level views will not be shown.String"year"False