Skip to content

Month Picker

Choose one calendar month from a focused year grid.

Usage

Billing month

Choose the calendar month used for the next billing cycle.

Choose the calendar month used for the next billing cycle.

Fiscal year

Move by year and choose one month from the active fiscal calendar.

Move by year and choose one month from the active fiscal calendar.

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

Floating positioning

This component uses the shared positioning engine. Use the live positioning example to change side, align, offsets, collision boundaries, strategy, and tracking while inspecting the resolved placement.

API

Vue package: @sectile/vue/temporal/month-picker

Components
  • MonthPickerRoot
  • MonthPickerTrigger
  • MonthPickerAnchor
  • MonthPickerPortal
  • MonthPickerContent
  • MonthPickerGrid
  • MonthPickerCell
  • MonthPickerInput
  • MonthPickerPreviousYear
  • MonthPickerNextYear

Props

MonthPickerRootProps

align

Alignment of positioned content relative to its anchor.

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

avoidCollisions

Whether positioned content may flip or shift to remain visible.

collisionBoundary

Boundary used to keep positioned content visible.

collisionPadding

Space kept between positioned content and its collision boundary.

defaultHighlightedValue

Initially highlighted value for uncontrolled state.

defaultOpen

Initial uncontrolled open state.

defaultValue

Initial value used when the component owns its state.

defaultView

Initial calendar or picker view.

disabled

Whether interaction is unavailable.

hideWhenDetached

Whether positioned content hides when its anchor leaves the layout.

highlightedValue

Value currently highlighted for keyboard interaction.

label

Accessible name announced for the control.

modelValue

Current value when state is controlled by the parent.

open

Whether the associated popup or disclosure is open.

policies

Behavior policies that customize validation, movement, or selection.

position

Whether the popup is positioned relative to its trigger.

readonly

Whether the value can be inspected but not changed.

referenceDate

Deterministic civil date used when a calendar has no selected or highlighted value.

required

Whether the control must contain a valid value before submission.

side

Preferred side of the anchor for positioned content.

sideOffset

Distance between positioned content and its anchor.

strategy

CSS positioning strategy used for anchored content.

tracking

Update strategy used while anchored content is open.

MonthPickerPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

MonthPickerPortalProps

defer

Whether Teleport target resolution waits until the end of the current mount or update tick.

disabled

Whether interaction is unavailable.

to

Teleport target for portalled content.

Slots

MonthPickerRootSlotProps

dates

Dates projected by the active view.

disabled

Whether interaction is unavailable.

highlightedValue

Value currently highlighted for interaction.

months

Months projected by the active view.

open

Whether the associated popup or disclosure is open.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

view

Current calendar anchor.

viewMode

Active calendar view mode.

years

Years projected by the active view.

MonthPickerCellSlotProps

disabled

Whether interaction is unavailable.

highlighted

Whether this item is highlighted for interaction.

inRange

Whether this value lies inside the selected range.

selected

Whether this item is selected.

value

Current value exposed by this contract.

Other types

MonthPickerValueChangeHandler

ts
type MonthPickerValueChangeHandler = NonNullable<InstanceType<typeof MonthPickerRoot>['$props']['onUpdate:modelValue']>

MonthPickerOpenChangeHandler

ts
type MonthPickerOpenChangeHandler = NonNullable<InstanceType<typeof MonthPickerRoot>['$props']['onUpdate:open']>

MonthPickerHighlightedValueChangeHandler

ts
type MonthPickerHighlightedValueChangeHandler = NonNullable<InstanceType<typeof MonthPickerRoot>['$props']['onUpdate:highlightedValue']>

MonthPickerValue

NameTypeRequired
yearnumberYes
monthnumberYes
daynumberYes

Parts

Shared scope: [data-scope="month-picker"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
input[data-part="input"]Accepts the editable value or draft.
anchor[data-part="anchor"]Provides the positioning reference for floating content.
trigger[data-part="trigger"]Opens, closes, or activates the associated content.
content[data-part="content"]Contains the component content shown for the active state.
grid[data-part="grid"]Groups cells into a navigable two-dimensional structure.
cell[data-part="cell"]Represents one navigable or selectable grid value.
previous-year[data-part="previous-year"]Moves to the previous year.
next-year[data-part="next-year"]Moves to the next year.

Keyboard interaction

KeyBehavior
Arrow keysMove between months in the year grid.
Page Up / Page DownMove to the previous or next year.
Enter / SpaceSelect the highlighted month.
EscapeClose the month grid without changing the value.

Accessibility

The labeled input and trigger own a year grid whose cells expose selected, highlighted, and disabled month state.

Released under the MIT License.