Skip to content

MazDatePicker

A powerful and flexible date picker component with support for single dates, date ranges, time selection, and extensive customization options

Before use it, you should install the MazUi plugin in your project, follow instructions in Getting Started

TIP

This component can be translated globally using the MazUi plugin.

Table of Contents

Basic Usage

The simplest way to use MazDatePicker:

Date Formats

Understanding date formats is crucial for using MazDatePicker effectively. The component uses two different format concepts:

1. Data Format (format prop)

This controls how dates are stored and transmitted in your v-model. Default is 'YYYY-MM-DD'.

2. Display Format (input-date-format prop)

This controls how dates appear in the input field using Intl.DateTimeFormatOptions.

Custom Display Transformation

Use inputDateTransformer to completely customize how dates appear in the input:

Date Selection

Standard Date Picker


Inline Date Picker

Perfect for dashboards or when you want the calendar always visible:

-
-
SunMonTueWedThuFriSat

Double Calendar

Show two months at once for better date selection:

Time Selection

Date + Time (24h format)

Date + Time (12h format)

Time Only Selection

Custom Minute Intervals

Range Selection

For selecting date ranges, pass an object with start and end properties:

Range with Shortcuts

Provide predefined shortcuts for common date ranges:

Property shortcuts

Model

ts
interface MazDatePickerShortcut {
  identifier: string // should be uniq
  label: string
  value: {
    start: string
    end: string
  }
}

type MazDatePickerShortcuts = MazDatePickerShortcut[]

Example

ts
import type { MazDatePickerShortcut } from 'maz-ui/components'

const shortcuts: MazDatePickerShortcut[] = [{
  label: 'Next month',
  identifier: 'nextMonth',
  value: {
    start: dayjs().add(1, 'month').set('date', 1).format('YYYY-MM-DD'),
    end: dayjs()
      .add(1, 'month')
      .set('date', dayjs().add(1, 'month').daysInMonth())
      .format('YYYY-MM-DD'),
  },
}]
View default shortcuts
ts
const shortcuts = [
  {
    label: 'Last 7 days',
    identifier: 'last7Days',
    value: {
      start: dayjs().subtract(6, 'day').format('YYYY-MM-DD'),
      end: dayjs().format('YYYY-MM-DD'),
    },
  },
  {
    label: 'Last 30 days',
    identifier: 'last30Days',
    value: {
      start: dayjs().subtract(29, 'day').format('YYYY-MM-DD'),
      end: dayjs().format('YYYY-MM-DD'),
    },
  },
  {
    label: 'This week',
    identifier: 'thisWeek',
    value: {
      start: dayjs().startOf('week').format('YYYY-MM-DD'),
      end: dayjs().endOf('week').format('YYYY-MM-DD'),
    },
  },
  {
    label: 'Last week',
    identifier: 'lastWeek',
    value: {
      start: dayjs()
        .subtract(1, 'week')
        .startOf('week')
        .format('YYYY-MM-DD'),
      end: dayjs().subtract(1, 'week').endOf('week').format('YYYY-MM-DD'),
    },
  },
  {
    label: 'This month',
    identifier: 'thisMonth',
    value: {
      start: dayjs().set('date', 1).format('YYYY-MM-DD'),
      end: dayjs()
        .set('date', dayjs().daysInMonth())
        .format('YYYY-MM-DD'),
    },
  },
  {
    label: 'This year',
    identifier: 'thisYear',
    value: {
      start: dayjs().startOf('year').format('YYYY-MM-DD'),
      end: dayjs().endOf('year').format('YYYY-MM-DD'),
    },
  },
  {
    label: 'Last year',
    identifier: 'lastYear',
    value: {
      start: dayjs()
        .subtract(1, 'year')
        .startOf('year')
        .format('YYYY-MM-DD'),
      end: dayjs().subtract(1, 'year').endOf('year').format('YYYY-MM-DD'),
    },
  },
]

Validation & Constraints

Min/Max Dates


Min: 2026-01-22 | Max: 2026-02-11

Property min-max-auto

Disable min-max auto check to not change the value when it is out of range

Disabled Days & Dates


Disabled Hours


Internationalization

MazDatePicker supports full internationalization. By default, it uses the locale from the MazUiTranslations plugin, but you can override it:

Types

typescript
// Value types
type MazDatePickerValue = string | undefined | MazDatePickerPartialRangeValue

interface MazDatePickerRangeValue {
  start: string
  end: string
}

type MazDatePickerPartialRangeValue = Partial<MazDatePickerRangeValue>

// Shortcut type
interface MazDatePickerShortcut {
  identifier: string
  label: string
  value: {
    start: string
    end: string
  }
}

Tips

TIP

This component use MazInput, so it inherits all his props

Props

NameDescriptionTypeRequiredDefaultPossible values
idThe unique identifier of the componentstringNoundefined-
styleThe inline style object for the componentHTMLAttributes['style']Noundefined-
classThe CSS class(es) to apply to the componentHTMLAttributes['class']Noundefined-
input-propsThe props to apply to the input componentMazInputPropsNoundefined-
model-valueThe value of the date picker component If an object is provided, the picker will be a range pickerMazDatePickerValueNoundefined-
formatThe format pattern for date display and parsing
Example: 'YYYY-MM-DD', 'DD/MM/YYYY', 'YYYY-MM-DD HH:mm'
stringNo'YYYY-MM-DD'-
openv-model:open
Controls whether the picker window is open
booleanNofalse-
labelThe label text displayed above the input fieldstringNoundefined-
placeholderThe placeholder text shown when no value is selectedstringNoundefined-
input-date-formatThe Intl.DateTimeFormatOptions for styling the input date displayIntl.DateTimeFormatOptionsNo() => ({ dateStyle: 'medium', timeStyle: 'short' })-
input-date-transformerCustom function to transform the formatted date displayFunctionNoundefined-
localeThe locale string for date formatting and localization
Example: 'en-US', 'fr-FR', 'de-DE'
stringNoundefined-
hide-headerControls whether the calendar header is hiddenbooleanNofalse-
disabledControls whether the component is disabledbooleanNofalse-
first-day-of-weekThe first day of the week in the calendar
Example: 0 (Sunday), 1 (Monday), 6 (Saturday)
0 | 1 | 2 | 3 | 4 | 5 | 6No00, 1, 2, 3, 4, 5, 6
auto-closeControls whether the picker closes automatically after date selectionbooleanNofalse-
custom-element-selectorCSS selector for a custom element that triggers the picker
Example: '#my-button', '.trigger-class'
stringNoundefined-
doubleControls whether the picker displays two months side by sidebooleanNofalse-
inlineControls whether the picker is displayed inline without input fieldbooleanNofalse-
colorThe color theme of the componentMazColorNo'primary'primary, secondary, success, destructive, warning, info, accent, contrast
picker-positionThe position where the picker popover should appearMazPopoverProps['position']No'auto'top, bottom, left, right, top-end, bottom-end, left-end, right-end, top-start, bottom-start, left-start, right-start
picker-prefer-positionThe preferred position of the picker popoverMazPopoverProps['preferPosition']No'bottom-start'top, bottom, left, right, top-end, bottom-end, left-end, right-end, top-start, bottom-start, left-start, right-start
picker-fallback-positionThe fallback position of the picker popoverMazPopoverProps['fallbackPosition']No'top-start'top, bottom, left, right, top-end, bottom-end, left-end, right-end, top-start, bottom-start, left-start, right-start
timeControls whether the picker includes a time selectorbooleanNofalse-
only-timeControls whether the picker shows only time selection (no date)booleanNofalse-
minute-intervalThe interval in minutes for the time picker minute selectionnumberNo51, 5, 10, 15, 30
use-browser-localeControls whether to automatically detect and use the browser's localebooleanNotrue-
fetch-localControls whether to fetch locale data dynamicallybooleanNotrue-
shortcutsArray of predefined date range shortcuts or false to disableMazDatePickerShortcut[] | falseNotrue-
shortcutThe identifier of the currently selected shortcutMazDatePickerShortcut['identifier']Noundefined-
min-dateThe minimum selectable date in ISO format
Example: '2023-01-01'
stringNoundefined-
max-dateThe maximum selectable date in ISO format
Example: '2024-12-31'
stringNoundefined-
min-max-autoWhen minDate or maxDate are provided, if the current date is not between minDate and maxDate, the current date will be set to the minDate or maxDatebooleanNotrue-
disabled-weeklyArray of weekday numbers to disable (0 = Sunday, 6 = Saturday)
Example: [0, 6] to disable weekends
number[]No() => []-
disabled-datesArray of specific dates to disable in ISO format
Example: ['2023-12-25', '2024-01-01']
string[]No() => []-
disabled-hoursArray of hour numbers to disable in the time picker (0-23)
Example: [0, 1, 2, 22, 23] to disable night hours
number[]No() => []-
blockControls whether the input displays in full widthbooleanNofalse-
rangeControls whether the picker operates in range selection modebooleanNofalse-
transitionThe transition name of the popoverMazPopoverProps['transition']No'scale-fade'-

Events

Event namePropertiesDescription
update:model-valuevalue MazDatePickerValue | undefined - The new selected valueEmitted when the picker value changes
closeEmitted when the picker closes

Slots

NameDescriptionBindings
triggerReplace the default input with your own elementis-open boolean - Current open state of the popover
close function - Function to close the popover
open function - Function to open the popover
toggle function - Function to toggle the popover