Skip to content

Year Picker

Free

Pick a year from a page of 12 years, with page turns and arrow keys. Limits and closed years keep the pick in range.

  • Base UI
  • React Aria
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Put the header and the grid in the picker. The grid gives a function that returns one cell for each year.

model-year.tsx

YearPicker

<fieldset>
PropTypeDefaultDescription
autoFocusbooleanfalseMoves the focus to the selected year (or the first year) on mount.
disabledbooleanfalseTurns off the control: no focus, no edits, and the disabled look.
readOnlybooleanfalseThe user can focus and read the value, but cannot change it.
invalidbooleanfalseShows the invalid look and sets aria-invalid.
labels—The words (YEAR_PICKER_LABELS). Keep the object stable.
valueCalendarDate | null—January 1 of the selected year (controlled).
defaultValueCalendarDate | null—
onValueChange—Called with January 1 of the picked year, in the calendar of the value (else Gregorian), on every pick: a press on the year that is the value already calls it again, as in React Aria Calendar, so a popup that closes on onValueChange closes then too.
minValueDateValue | null—The earliest year that can be picked: years that end before it are disabled.
maxValueDateValue | null—The latest year that can be picked: years that start after it are disabled.
isYearUnavailable—Years that can take the focus but not the value: struck through. Gets January 1.
focusedValueDateValue—The focused year (controlled): the page starts 6 years before it.
defaultFocusedValueDateValue—The year that the first page is built around. Default: the value, else today. With server rendering and no value, pass it from the request: the server clock can be in another year.
onFocusChange—Called with January 1 of the new focused year when the page turns (12 years).
...props<fieldset> attributes—Every other attribute goes to the <fieldset>, with a ref.

YearPickerHeader

<header>
PropTypeDefaultDescription
...props<header> attributes—Every other attribute goes to the <header>, with a ref.

YearPickerGrid

PropTypeDefaultDescription
aria-labelstring—Defines a string value that labels the current element.
aria-labelledbystring—Identifies the element (or elements) that labels the current element.
aria-describedbystring—Identifies the element (or elements) that describes the object.
aria-detailsstring—Identifies the element (or elements) that provide a detailed, extended description for the object.
idstring—The element's unique identifier. See MDN.
dirstring—
langstring—
hiddenboolean—
inertboolean—
translate"no""yes"—
suppressHydrationWarningboolean—A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs.
onClickMouseEventHandler<HTMLDivElement>—
onClickCaptureMouseEventHandler<HTMLDivElement>—
onAuxClickMouseEventHandler<HTMLDivElement>—
onAuxClickCaptureMouseEventHandler<HTMLDivElement>—
onContextMenuMouseEventHandler<HTMLDivElement>—
onContextMenuCaptureMouseEventHandler<HTMLDivElement>—
onDoubleClickMouseEventHandler<HTMLDivElement>—
onDoubleClickCaptureMouseEventHandler<HTMLDivElement>—
onMouseDownMouseEventHandler<HTMLDivElement>—
onMouseDownCaptureMouseEventHandler<HTMLDivElement>—
onMouseEnterMouseEventHandler<HTMLDivElement>—
onMouseLeaveMouseEventHandler<HTMLDivElement>—
onMouseMoveMouseEventHandler<HTMLDivElement>—
onMouseMoveCaptureMouseEventHandler<HTMLDivElement>—
onMouseOutMouseEventHandler<HTMLDivElement>—
onMouseOutCaptureMouseEventHandler<HTMLDivElement>—
onMouseOverMouseEventHandler<HTMLDivElement>—
onMouseOverCaptureMouseEventHandler<HTMLDivElement>—
onMouseUpMouseEventHandler<HTMLDivElement>—
onMouseUpCaptureMouseEventHandler<HTMLDivElement>—
onTouchCancelTouchEventHandler<HTMLDivElement>—
onTouchCancelCaptureTouchEventHandler<HTMLDivElement>—
onTouchEndTouchEventHandler<HTMLDivElement>—
onTouchEndCaptureTouchEventHandler<HTMLDivElement>—
onTouchMoveTouchEventHandler<HTMLDivElement>—
onTouchMoveCaptureTouchEventHandler<HTMLDivElement>—
onTouchStartTouchEventHandler<HTMLDivElement>—
onTouchStartCaptureTouchEventHandler<HTMLDivElement>—
onPointerDownPointerEventHandler<HTMLDivElement>—
onPointerDownCapturePointerEventHandler<HTMLDivElement>—
onPointerMovePointerEventHandler<HTMLDivElement>—
onPointerMoveCapturePointerEventHandler<HTMLDivElement>—
onPointerUpPointerEventHandler<HTMLDivElement>—
onPointerUpCapturePointerEventHandler<HTMLDivElement>—
onPointerCancelPointerEventHandler<HTMLDivElement>—
onPointerCancelCapturePointerEventHandler<HTMLDivElement>—
onPointerEnterPointerEventHandler<HTMLDivElement>—
onPointerLeavePointerEventHandler<HTMLDivElement>—
onPointerOverPointerEventHandler<HTMLDivElement>—
onPointerOverCapturePointerEventHandler<HTMLDivElement>—
onPointerOutPointerEventHandler<HTMLDivElement>—
onPointerOutCapturePointerEventHandler<HTMLDivElement>—
onGotPointerCapturePointerEventHandler<HTMLDivElement>—
onGotPointerCaptureCapturePointerEventHandler<HTMLDivElement>—
onLostPointerCapturePointerEventHandler<HTMLDivElement>—
onLostPointerCaptureCapturePointerEventHandler<HTMLDivElement>—
onScrollUIEventHandler<HTMLDivElement>—
onScrollCaptureUIEventHandler<HTMLDivElement>—
onWheelWheelEventHandler<HTMLDivElement>—
onWheelCaptureWheelEventHandler<HTMLDivElement>—
onAnimationStartAnimationEventHandler<HTMLDivElement>—
onAnimationStartCaptureAnimationEventHandler<HTMLDivElement>—
onAnimationEndAnimationEventHandler<HTMLDivElement>—
onAnimationEndCaptureAnimationEventHandler<HTMLDivElement>—
onAnimationIterationAnimationEventHandler<HTMLDivElement>—
onAnimationIterationCaptureAnimationEventHandler<HTMLDivElement>—
onTransitionCancelTransitionEventHandler<HTMLDivElement>—
onTransitionCancelCaptureTransitionEventHandler<HTMLDivElement>—
onTransitionEndTransitionEventHandler<HTMLDivElement>—
onTransitionEndCaptureTransitionEventHandler<HTMLDivElement>—
onTransitionRunTransitionEventHandler<HTMLDivElement>—
onTransitionRunCaptureTransitionEventHandler<HTMLDivElement>—
onTransitionStartTransitionEventHandler<HTMLDivElement>—
onTransitionStartCaptureTransitionEventHandler<HTMLDivElement>—
onFocus—Handler that is called when the element receives focus.
onBlur—Handler that is called when the element loses focus.
onFocusChange—Handler that is called when the element's focus status changes.
styleStyleOrFunction<ListBoxRenderProps>—The inline style for the element. A function may be provided to compute the style based on component state.
slotstring | null—A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.
render—Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if <button> is expected, you cannot render an <a>). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
autoFocus"first""last"boolean—Whether to auto focus the listbox or an option.
shouldFocusWrapboolean—Whether focus should wrap around when the end/start is reached.
shouldSelectOnPressUpboolean—Whether selection should occur on press up instead of press down.
shouldFocusOnHoverboolean—Whether options should be focused when the user hovers over them.
onAction—Handler that is called when a user performs an action on an item. The exact user event depends on the collection's selectionBehavior prop and the interaction modality.
dependenciesreadonly any[]—Values that should invalidate the item cache when using dynamic collections.
dragAndDropHooksDragAndDropHooks<object>—The drag and drop hooks returned by useDragAndDrop used to enable drag and drop behavior for the ListBox.
renderEmptyState—Provides content to display when there are no items in the list.
orientation"horizontal""vertical"'vertical'The primary orientation of the items. Usually this is the direction that the collection scrolls.
classNamestring—
refRef<HTMLDivElement>—The grid element. The component also uses it for the page motion.
children—A function from January 1 of a year to a YearPickerCell, for a labelSuffix or other content. Default: <YearPickerCell date={date} />.

YearPickerCell

PropTypeDefaultDescription
hrefstring—A URL to link to. See MDN.
hrefLangstring—Hints at the human language of the linked URL. SeeMDN.
target"_blank""_parent""_self""_top"string—The target window for the link. See MDN.
relstring—The relationship between the linked resource and the current page. See MDN.
downloadstring | boolean—Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
pingstring—A space-separated list of URLs to ping when the link is followed. See MDN.
referrerPolicy"""no-referrer""no-referrer-when-downgrade""origin""origin-when-cross-origin""same-origin""strict-origin""strict-origin-when-cross-origin""unsafe-url"—How much of the referrer to send when following the link. See MDN.
routerOptions—Options for the configured client side router.
dirstring—
langstring—
hiddenboolean—
inertboolean—
translate"no""yes"—
suppressHydrationWarningboolean—A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs.
onClickCaptureMouseEventHandler<HTMLDivElement>—
onAuxClickMouseEventHandler<HTMLDivElement>—
onAuxClickCaptureMouseEventHandler<HTMLDivElement>—
onContextMenuMouseEventHandler<HTMLDivElement>—
onContextMenuCaptureMouseEventHandler<HTMLDivElement>—
onDoubleClickMouseEventHandler<HTMLDivElement>—
onDoubleClickCaptureMouseEventHandler<HTMLDivElement>—
onMouseDownMouseEventHandler<HTMLDivElement>—
onMouseDownCaptureMouseEventHandler<HTMLDivElement>—
onMouseEnterMouseEventHandler<HTMLDivElement>—
onMouseLeaveMouseEventHandler<HTMLDivElement>—
onMouseMoveMouseEventHandler<HTMLDivElement>—
onMouseMoveCaptureMouseEventHandler<HTMLDivElement>—
onMouseOutMouseEventHandler<HTMLDivElement>—
onMouseOutCaptureMouseEventHandler<HTMLDivElement>—
onMouseOverMouseEventHandler<HTMLDivElement>—
onMouseOverCaptureMouseEventHandler<HTMLDivElement>—
onMouseUpMouseEventHandler<HTMLDivElement>—
onMouseUpCaptureMouseEventHandler<HTMLDivElement>—
onTouchCancelTouchEventHandler<HTMLDivElement>—
onTouchCancelCaptureTouchEventHandler<HTMLDivElement>—
onTouchEndTouchEventHandler<HTMLDivElement>—
onTouchEndCaptureTouchEventHandler<HTMLDivElement>—
onTouchMoveTouchEventHandler<HTMLDivElement>—
onTouchMoveCaptureTouchEventHandler<HTMLDivElement>—
onTouchStartTouchEventHandler<HTMLDivElement>—
onTouchStartCaptureTouchEventHandler<HTMLDivElement>—
onPointerDownPointerEventHandler<HTMLDivElement>—
onPointerDownCapturePointerEventHandler<HTMLDivElement>—
onPointerMovePointerEventHandler<HTMLDivElement>—
onPointerMoveCapturePointerEventHandler<HTMLDivElement>—
onPointerUpPointerEventHandler<HTMLDivElement>—
onPointerUpCapturePointerEventHandler<HTMLDivElement>—
onPointerCancelPointerEventHandler<HTMLDivElement>—
onPointerCancelCapturePointerEventHandler<HTMLDivElement>—
onPointerEnterPointerEventHandler<HTMLDivElement>—
onPointerLeavePointerEventHandler<HTMLDivElement>—
onPointerOverPointerEventHandler<HTMLDivElement>—
onPointerOverCapturePointerEventHandler<HTMLDivElement>—
onPointerOutPointerEventHandler<HTMLDivElement>—
onPointerOutCapturePointerEventHandler<HTMLDivElement>—
onGotPointerCapturePointerEventHandler<HTMLDivElement>—
onGotPointerCaptureCapturePointerEventHandler<HTMLDivElement>—
onLostPointerCapturePointerEventHandler<HTMLDivElement>—
onLostPointerCaptureCapturePointerEventHandler<HTMLDivElement>—
onScrollUIEventHandler<HTMLDivElement>—
onScrollCaptureUIEventHandler<HTMLDivElement>—
onWheelWheelEventHandler<HTMLDivElement>—
onWheelCaptureWheelEventHandler<HTMLDivElement>—
onAnimationStartAnimationEventHandler<HTMLDivElement>—
onAnimationStartCaptureAnimationEventHandler<HTMLDivElement>—
onAnimationEndAnimationEventHandler<HTMLDivElement>—
onAnimationEndCaptureAnimationEventHandler<HTMLDivElement>—
onAnimationIterationAnimationEventHandler<HTMLDivElement>—
onAnimationIterationCaptureAnimationEventHandler<HTMLDivElement>—
onTransitionCancelTransitionEventHandler<HTMLDivElement>—
onTransitionCancelCaptureTransitionEventHandler<HTMLDivElement>—
onTransitionEndTransitionEventHandler<HTMLDivElement>—
onTransitionEndCaptureTransitionEventHandler<HTMLDivElement>—
onTransitionRunTransitionEventHandler<HTMLDivElement>—
onTransitionRunCaptureTransitionEventHandler<HTMLDivElement>—
onTransitionStartTransitionEventHandler<HTMLDivElement>—
onTransitionStartCaptureTransitionEventHandler<HTMLDivElement>—
onKeyDown—Handler that is called when a key is pressed.
onKeyUp—Handler that is called when a key is released.
onFocus—Handler that is called when the element receives focus.
onBlur—Handler that is called when the element loses focus.
onFocusChange—Handler that is called when the element's focus status changes.
onHoverStart—Handler that is called when a hover interaction starts.
onHoverEnd—Handler that is called when a hover interaction ends.
onHoverChange—Handler that is called when the hover state changes.
onPress—Handler that is called when the press is released over the target.
onPressStart—Handler that is called when a press interaction starts.
onPressEnd—Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange—Handler that is called when the press state changes.
onPressUp—Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
onClick—**Not recommended – use onPress instead.** onClick is an alias for onPress provided for compatibility with other libraries. onPress provides additional event details for non-mouse interactions.
styleStyleOrFunction<ListBoxItemRenderProps>—The inline style for the element. A function may be provided to compute the style based on component state.
render—Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Note: You can check if 'href' in props in order to tell whether to render an <a> element. Requirements: - You must render the expected element type (e.g. if <a> is expected, you cannot render a <button>). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
aria-labelstring—An accessibility label for this item.
onAction—Handler that is called when a user performs an action on the item. The exact user event depends on the collection's selectionBehavior prop and the interaction modality.
disabledboolean—Turns off the control: no focus, no edits, and the disabled look.
dateRequiredCalendarDate—January 1 of the year (from the YearPickerGrid function).
classNamestring—
labelSuffixstring—Words that the cell name adds after the year: "no records".
childrenReactNode—Replaces the year label. The current-year dot stays after it.
  • Use it when only the year matters.
  • Use minValue, maxValue, and isYearUnavailable to block years.
  • Put it in a popover under a field for a form.
Arrow keysMove one year, or one row. Past an edge the page turns.
HomeorEndGo to the first or the last year of the page.
Page UporPage DownGo 12 years back or on.
EnterPicks the focused year.

Built with

Installs with Year Picker

Components
Button
  1. AddedYear Picker, with Button.
Open the release