Skip to content
On this page

Datepicker

An input with a simple dropdown/modal for selecting a date, uses native datepicker for mobile

Examples

Base

Selected: Thu Sep 21 2023 13:06:38 GMT+0000 (Coordinated Universal Time)

Show code

Min/Max date

Show code

Range

Selected: Thu Sep 21 2023 13:06:38 GMT+0000 (Coordinated Universal Time)

Show code

Multiple

Selected: []

Show code

Trigger

Show code

Programmatically

Show code

Slots

Show code

Events

Show code

Month picker

Show code

Class props

'Classes applied to the element'
How does the Class props inspector work?
Class propDescriptionPropsSuffixes
boxClassClass of the Datepicker box where you choose the date.
dropdownClassesClasses to apply on dropdown. More detail here
footerClassClass of the Datepicker footer.
headerButtonsClassClass of the Datepicker buttons inside the box.
headerButtonsSizeClassClass of the Datepicker buttons inside the box when a size is choosen.sizesmall
medium
large
headerClassClass of the Datepicker header inside the box.
inputClassesClasses to apply on internal input. More detail here
listsClassClass of the month and year selects container inside the Datepicker box.
🔍 Classes applied have a higher specificity than expected when mobileClass is applied
mobileClassClass of the Datepicker when on mobile.
👉 Switch to mobile view to see it in action!
monthBodyClassClass of the table body inside the box when type is month.
monthCellClassClass of the table cell when type is month.
monthCellFirstHoveredClassClass of the first hovered table cell during range selection when type is month.
👉 See it in action selecting a date range
monthCellFirstSelectedClassClass of the first selected table cell when in range when type is month.
👉 See it in action selecting a date range
monthCellInvisibleClassClass of the table cell when nearby month days are hidden when type is month.
monthCellLastHoveredClassClass of the last table cell hovered during range selection when type is month.
👉 See it in action selecting a date range
monthCellLastSelectedClassClass of the last selected table cell during range selection when type is month.
👉 See it in action selecting a date range
monthCellNearbyClassClass of the table cell when nearby days (prev/next month) are selectable when type is month.
monthCellSelectableClassClass of the table cell that is selectable when type is month.
monthCellSelectedClassClass of table cell when it's selected when type is month.
monthCellTodayClassClass of the table cell of the current day when type is month.
monthCellUnselectableClassClass of the table cell that is unselectable when type is month.
monthCellWithinHoveredClassClass of the table cell when hovered during range selection when type is month.
👉 See it in action selecting a date range
monthCellWithinSelectedClassClass of the table cells within the range when the range is selected when type is month.
👉 See it in action selecting a date range
monthClassClass of the Datepicker table inside the box when type is month.
monthEventsClassClass of the events container when type is month.
monthRowClassClass of the table row when type is month.
nextBtnClassClass of the next button inside the Datepicker box.
🔍 Classes applied have a higher specificity than expected when mobileClass is applied
prevBtnClassClass of the prev. button inside the Datepicker box.
🔍 Classes applied have a higher specificity than expected when mobileClass is applied
rootClassClass of the root element.
selectListClassesClasses to apply on select list (month and year). More detail here
sizeClassClass of the Datepicker size.sizesmall
medium
large
tableBodyClassClass of the table body inside the box.
tableCellClassClass of the table cell.
tableCellEventsClassClass of the cell of a row when at least one event is present.
tableCellFirstHoveredClassClass of the first hovered table cell during range selection.
👉 See it in action selecting a date range
tableCellFirstSelectedClassClass of the first selected table cell when in range.
👉 See it in action selecting a date range
tableCellInvisibleClassClass of the table cell when nearby month days are hidden.
tableCellLastHoveredClassClass of the last table cell hovered during range selection.
👉 See it in action selecting a date range
tableCellLastSelectedClassClass of the last selected table cell during range selection.
👉 See it in action selecting a date range
tableCellNearbyClassClass of the table cell when nearby days (prev/next month) are selectable.
tableCellSelectableClassClass of the table cell that is selectable.
tableCellSelectedClassClass of table cell when it's selected.
tableCellTodayClassClass of the table cell of the current day.
tableCellUnselectableClassClass of the table cell that is unselectable.
tableCellWithinHoveredClassClass of the table cell when hovered during range selection.
👉 See it in action selecting a date range
tableCellWithinSelectedClassClass of the table cells within the range when the range is selected.
👉 See it in action selecting a date range
tableClassClass of the Datepicker table inside the box.
tableEventClassClass of the event.
tableEventIndicatorsClassClass of the event indicator.indicatorbars
dots
*
tableEventVariantClassClass of the event indicator when a `variant` is specified.variant in eventprimary
info
warning
danger
tableEventsClassClass of the events container.
tableHeadCellClassClass of the cell inside the table header.
tableHeadClassClass of Datepicker header with days of the week inside the table.
tableRowClassClass of the table row.

Datepicker component

html
<o-datepicker></o-datepicker>

Props

Prop nameDescriptionTypeValuesDefault
appendToBodyboolean-
ariaNextLabelstring-
ariaPreviousLabelstring-
autocompleteNative options to use in HTML5 validationstring-
closeOnClickboolean-true
dateCreatorfunc-Default function (see source code)
dateFormatterfunc-Default function (see source code)
dateParserfunc-Default function (see source code)
dayNamesarray-
From config:
datepicker: {
  dayNames: undefined
}
disabledboolean-
editableboolean-
eventsarray-
expandedMakes input full width when inside a grouped or addon fieldboolean-
firstDayOfWeeknumber-
From config:
datepicker: {
  firstDayOfWeek: 0
}
focusedDateDate-
iconIcon name to be addedstring-
iconNextstring-
From config:
datepicker: {
  iconNext: 'chevron-right'
}
iconPackIcon pack to usestringmdi, fa, fas and any other custom icon pack
iconPrevstring-
From config:
datepicker: {
  iconPrev: 'chevron-left'
}
iconRightstring-
iconRightClickableboolean-
indicatorsstring-'dots'
inlineboolean-
localestring|array-
From config:
{
   locale: undefined
}
maxDateDate-
maxlengthSame as native maxlength, plus character counternumber|string-
minDateDate-
mobileBreakpointMobile breakpoint as max-width valuestring-
mobileModalboolean-
From config:
datepicker: {
  mobileModal: true
}
mobileNativeboolean-
From config:
datepicker: {
  mobileNative: true
}
modelValuedate|array-
monthNamesarray-
From config:
datepicker: {
  monthNames: undefined
}
multipleboolean-false
nearbyMonthDaysboolean-
From config:
datepicker: {
  nearbyMonthDays: true
}
nearbySelectableMonthDaysboolean-
From config:
datepicker: {
  nearbySelectableMonthDays: false
}
openOnFocusboolean-
overrideboolean-
placeholderstring-
positionstring-
rangeboolean-false
roundedMakes the element roundedboolean-
rulesForFirstWeeknumber-Default function (see source code)
selectableDatesarray|func-
showWeekNumberboolean-
From config:
datepicker: {
  showWeekNumber: false
}
sizeSize of button, optionalstringsmall, medium, large
statusIconShow status icon using field and variant propboolean-
From config:
{
   "statusIcon": true
}
trapFocusboolean-
From config:
datepicker: {
  trapFocus: true
}
typestring-
unselectableDatesarray|func-
unselectableDaysOfWeekarray-
From config:
datepicker: {
  unselectableDaysOfWeek: undefined
}
useHtml5ValidationEnable html 5 native validationboolean-
From config:
{
   "useHtml5Validation": true
}
validationMessageThe message which is shown when a validation error occursstring-
weekNumberClickableboolean-
From config:
datepicker: {
  weekNumberClickable: false
}
yearsRangearray-
From config:
datepicker: {
  yearsRange: [-100, 10]
}

Events

Event namePropertiesDescription
icon-right-click
range-start
range-end
blur
focus
invalid
update:modelValue
change-month
change-year
active-change

Slots

NameDescriptionBindings
trigger
header
table
footer

Sass variables

Current theme ➜ Oruga Base

SASS VariableDefault
$datepicker-font-size$base-font-size
$datepicker-box-line-height$base-line-height
$datepicker-box-padding0.375rem 1rem
$datepicker-header-padding0 0 0.875rem 0
$datepicker-header-margin0 0 0.875rem 0
$datepicker-header-border-bottom1px solid $grey-lighter
$datepicker-footer-padding0.875rem 0.5rem 0 0.5rem
$datepicker-footer-margin0.875rem 0 0.875rem 0
$datepicker-footer-border-top1px solid $grey-lighter
$datepicker-table-head-padding0 0 0.875rem 0
$datepicker-table-head-margin0 0 0.875rem 0
$datepicker-table-head-border-bottom1px solid $grey-lighter
$datepicker-table-head-item-color$grey
$datepicker-table-head-item-font-weight600
$datepicker-item-today-bordersolid 1px rgba($primary, 0.5)
$datepicker-item-selectable-color$grey-dark
$datepicker-item-disabled-color$grey-light
$datepicker-item-border-radius$base-border-radius
$datepicker-item-padding0.5rem 0.75rem
$datepicker-item-selected-color$primary-invert
$datepicker-item-selected-background-color$primary
$datepicker-item-selected-border-radius0
$datepicker-item-selected-within-background-colorrgba( $datepicker-item-selected-background-color, 0.5)
$datepicker-item-hovered-background-color$grey
$datepicker-item-hovered-color$grey-lighter
$datepicker-item-hovered-background-color#f5f5f5
$datepicker-item-hovered-within-background-colorrgba( $datepicker-item-hovered-background-color, 0.5)
$datepicker-item-nearby-color$grey-light
$datepicker-events-item-padding0.3rem 0.75rem 0.75rem
$datepicker-event-background-color$grey-light
$datepicker-event-dots-size0.35em
$datepicker-event-dots-margin0 0.1em
$datepicker-event-bars-height0.25em
$datepicker-btn-border-color$grey-lighter
$datepicker-btn-border-radius$base-border-radius
$datepicker-btn-border1px solid transparent
$datepicker-btn-color#363636
$datepicker-btn-height2.25em
$datepicker-btn-hover-border-color$grey-light
$datepicker-btn-hover-color#363636
$datepicker-btn-line-height$base-line-height
$datepicker-btn-margin0.25rem
$datepicker-btn-min-width2.25em
$datepicker-btn-padding0.5em 0.5em

See ➜ 📄 Full scss file

Current theme ➜ Oruga Full

SASS VariableDefault
$datepicker-font-size$base-font-size
$datepicker-box-line-height$base-line-height
$datepicker-box-padding0.375rem 1rem
$datepicker-header-padding0 0 0.875rem 0
$datepicker-header-margin0 0 0.875rem 0
$datepicker-header-border-bottom1px solid $grey-lighter
$datepicker-footer-padding0.875rem 0.5rem 0 0.5rem
$datepicker-footer-margin0.875rem 0 0.875rem 0
$datepicker-footer-border-top1px solid $grey-lighter
$datepicker-table-head-padding0 0 0.875rem 0
$datepicker-table-head-margin0 0 0.875rem 0
$datepicker-table-head-border-bottom1px solid $grey-lighter
$datepicker-table-head-item-color$grey
$datepicker-table-head-item-font-weight600
$datepicker-item-today-bordersolid 1px rgba($primary, 0.5)
$datepicker-item-selectable-color$grey-dark
$datepicker-item-disabled-color$grey-light
$datepicker-item-border-radius$base-border-radius
$datepicker-item-padding0.5rem 0.75rem
$datepicker-item-selected-color$primary-invert
$datepicker-item-selected-background-color$primary
$datepicker-item-selected-border-radius0
$datepicker-item-selected-within-background-colorrgba( $datepicker-item-selected-background-color, 0.5)
$datepicker-item-hovered-background-color$grey
$datepicker-item-hovered-color$grey-lighter
$datepicker-item-hovered-background-color#f5f5f5
$datepicker-item-hovered-within-background-colorrgba( $datepicker-item-hovered-background-color, 0.5)
$datepicker-item-nearby-color$grey-light
$datepicker-events-item-padding0.3rem 0.75rem 0.75rem
$datepicker-event-background-color$grey-light
$datepicker-event-dots-size0.35em
$datepicker-event-dots-margin0 0.1em
$datepicker-event-bars-height0.25em
$datepicker-btn-border-color$grey-lighter
$datepicker-btn-border-radius$base-border-radius
$datepicker-btn-border1px solid transparent
$datepicker-btn-color#363636
$datepicker-btn-height2.25em
$datepicker-btn-hover-border-color$grey-light
$datepicker-btn-hover-color#363636
$datepicker-btn-line-height$base-line-height
$datepicker-btn-margin0.25rem
$datepicker-btn-min-width2.25em
$datepicker-btn-padding0.5em 0.5em

See ➜ 📄 Full scss file

Current theme ➜ Bulma

The theme does not have any custom variables for this component.

Current theme ➜ Bootstrap

SASS VariableDefault
$datepicker-background-colorvar(--#{$prefix}body-bg)
$datepicker-pagination-spacercalc($spacer * 0.5)
$datepicker-section-spacercalc($spacer * 0.75)
$datepicker-section-border1px solid var(--#{$prefix}border-color)
$datepicker-cell-padding0.5rem 0.75rem
$datepicker-cell-widthcalc(#{100%} / 7)
$datepicker-cell-border-radiusvar(--#{$prefix}border-radius)
$datepicker-cell-font-weight400
$datepicker-cell-colorvar(--#{$prefix}black)
$datepicker-cell-hovered-colorvar(--#{$prefix}secondary)
$datepicker-cell-selected-colorvar(--#{$prefix}primary)
$datepicker-month-width20rem
$datepicker-month-cell-spacercalc($spacer * 0.5)
$datepicker-month-cell-height2.5rem
$datepicker-dropdown-widthcalc(100vw - 40px)
$datepicker-dropdown-max-width460px

See ➜ 📄 Full scss file

Released under the MIT License.