---
title: "Year Picker"
description: "Pick a year from a page of 12 years, with page turns and arrow keys. Limits and closed years keep the pick in range."
url: https://gelatinui.com/components/year-picker
markdown_url: https://gelatinui.com/components/year-picker.md
access: free
install: "npx shadcn@latest add @gelatin-ui/year-picker"
registry_item: https://gelatinui.com/r/year-picker.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Year Picker

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

Page: https://gelatinui.com/components/year-picker

## When to use it

Best for: Picking a year from a page of 12 years, with limits and unavailable years.

- 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.

## When not to use it

- To pick a month, use a [Month Picker](https://gelatinui.com/components/month-picker.md).
- To pick a day, use a [Calendar](https://gelatinui.com/components/calendar.md).

## Notes for agents

- The value is a `CalendarDate` on January 1.
- It renders a `fieldset`. Name it with `aria-label`. The default name is the page heading.
- The first page starts 6 years before the focused year. A pick does not turn the page.
- It has no form value. Add a hidden input to send it in a form.

## Anatomy

```text
YearPicker
├─ YearPickerHeader (0..n)
├─ YearPickerGrid (0..n)
└─ YearPickerCell (0..n)
```

## API reference

### YearPicker

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `autoFocus` | `boolean` | false | Moves the focus to the selected year (or the first year) on mount. |
| `disabled` | `boolean` | false | Turns off the control: no focus, no edits, and the disabled look. |
| `readOnly` | `boolean` | false | The user can focus and read the value, but cannot change it. |
| `invalid` | `boolean` | false | Shows the invalid look and sets `aria-invalid`. |
| `labels` | `Partial<typeof YEAR_PICKER_LABELS>` |  | The words (`YEAR_PICKER_LABELS`). Keep the object stable. |
| `value` | `CalendarDate \| null` |  | January 1 of the selected year (controlled). |
| `defaultValue` | `CalendarDate \| null` |  |  |
| `onValueChange` | `function` |  | 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. |
| `minValue` | `DateValue \| null` |  | The earliest year that can be picked: years that end before it are disabled. |
| `maxValue` | `DateValue \| null` |  | The latest year that can be picked: years that start after it are disabled. |
| `isYearUnavailable` | `function` |  | Years that can take the focus but not the value: struck through. Gets January 1. |
| `focusedValue` | `DateValue` |  | The focused year (controlled): the page starts 6 years before it. |
| `defaultFocusedValue` | `DateValue` |  | 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` | `function` |  | Called with January 1 of the new focused year when the page turns (12 years). |

### YearPickerHeader

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### YearPickerGrid

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. |
| `aria-labelledby` | `string` |  | Identifies the element (or elements) that labels the current element. |
| `aria-describedby` | `string` |  | Identifies the element (or elements) that describes the object. |
| `aria-details` | `string` |  | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| `id` | `string` |  | The element's unique identifier. See MDN. |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | 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. |
| `onClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEnd` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRun` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStart` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onFocus` | `function` |  | Handler that is called when the element receives focus. |
| `onBlur` | `function` |  | Handler that is called when the element loses focus. |
| `onFocusChange` | `function` |  | Handler that is called when the element's focus status changes. |
| `style` | `StyleOrFunction<ListBoxRenderProps>` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `slot` | `string \| 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` | `DOMRenderFunction` |  | 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` | `boolean \| FocusStrategy` |  | Whether to auto focus the listbox or an option. |
| `shouldFocusWrap` | `boolean` |  | Whether focus should wrap around when the end/start is reached. |
| `shouldSelectOnPressUp` | `boolean` |  | Whether selection should occur on press up instead of press down. |
| `shouldFocusOnHover` | `boolean` |  | Whether options should be focused when the user hovers over them. |
| `onAction` | `function` |  | 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. |
| `dependencies` | `readonly any[]` |  | Values that should invalidate the item cache when using dynamic collections. |
| `dragAndDropHooks` | `DragAndDropHooks<object>` |  | The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the ListBox. |
| `renderEmptyState` | `function` |  | Provides content to display when there are no items in the list. |
| `orientation` | `Orientation` | 'vertical' | The primary orientation of the items. Usually this is the direction that the collection scrolls. |
| `className` | `string` |  |  |
| `ref` | `Ref<HTMLDivElement>` |  | The grid element. The component also uses it for the page motion. |
| `children` | `function` |  | A function from January 1 of a year to a `YearPickerCell`, for a `labelSuffix` or other content. Default: `<YearPickerCell date={date} />`. |

### YearPickerCell

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `href` | `string` |  | A URL to link to. See MDN. |
| `hrefLang` | `string` |  | Hints at the human language of the linked URL. SeeMDN. |
| `target` | `HTMLAttributeAnchorTarget` |  | The target window for the link. See MDN. |
| `rel` | `string` |  | The relationship between the linked resource and the current page. See MDN. |
| `download` | `string \| boolean` |  | Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN. |
| `ping` | `string` |  | A space-separated list of URLs to ping when the link is followed. See MDN. |
| `referrerPolicy` | `HTMLAttributeReferrerPolicy` |  | How much of the referrer to send when following the link. See MDN. |
| `routerOptions` | `` |  | Options for the configured client side router. |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | 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. |
| `onClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEnd` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRun` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStart` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onKeyDown` | `function` |  | Handler that is called when a key is pressed. |
| `onKeyUp` | `function` |  | Handler that is called when a key is released. |
| `onFocus` | `function` |  | Handler that is called when the element receives focus. |
| `onBlur` | `function` |  | Handler that is called when the element loses focus. |
| `onFocusChange` | `function` |  | Handler that is called when the element's focus status changes. |
| `onHoverStart` | `function` |  | Handler that is called when a hover interaction starts. |
| `onHoverEnd` | `function` |  | Handler that is called when a hover interaction ends. |
| `onHoverChange` | `function` |  | Handler that is called when the hover state changes. |
| `onPress` | `function` |  | Handler that is called when the press is released over the target. |
| `onPressStart` | `function` |  | Handler that is called when a press interaction starts. |
| `onPressEnd` | `function` |  | Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. |
| `onPressChange` | `function` |  | Handler that is called when the press state changes. |
| `onPressUp` | `function` |  | Handler that is called when a press is released over the target, regardless of whether it started on the target or not. |
| `onClick` | `function` |  | **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. |
| `style` | `StyleOrFunction<ListBoxItemRenderProps>` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `render` | `function` |  | 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-label` | `string` |  | An accessibility label for this item. |
| `onAction` | `function` |  | 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. |
| `disabled` | `boolean` |  | Turns off the control: no focus, no edits, and the disabled look. |
| `date` | `CalendarDate` |  | January 1 of the year (from the `YearPickerGrid` function). |
| `className` | `string` |  |  |
| `labelSuffix` | `string` |  | Words that the cell name adds after the year: "no records". |
| `children` | `ReactNode` |  | Replaces the year label. The current-year dot stays after it. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| YearPicker | `year-picker` |  |  |  |
| YearPickerHeader | `year-picker-header` |  |  |  |
| YearPickerGrid | `year-picker-grid` |  |  |  |
| YearPickerCell | `year-picker-cell` | `data-disabled` |  |  |

## Usage

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

```tsx title="model-year.tsx"
"use client";

import { CalendarDate } from "@internationalized/date";
import { useState } from "react";

import {
  YearPicker,
  YearPickerCell,
  YearPickerGrid,
  YearPickerHeader,
} from "@/components/ui/year-picker";

export function ModelYear() {
  const [year, setYear] = useState(new CalendarDate(2021, 1, 1));
  return (
    <YearPicker
      aria-label="Model year"
      value={year}
      onValueChange={setYear}
      minValue={new CalendarDate(2016, 1, 1)}
      maxValue={new CalendarDate(2027, 12, 31)}
    >
      <YearPickerHeader />
      <YearPickerGrid>
        {(date) => {
          return <YearPickerCell date={date} />;
        }}
      </YearPickerGrid>
    </YearPicker>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/year-picker
```

It adds 30 registry items: 27 files, 4783 lines, and the npm packages `@base-ui/react`, `@internationalized/date`, `@mantine/hooks`, `@phosphor-icons/react`, `motion`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Button](https://gelatinui.com/components/button.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Month Picker](https://gelatinui.com/components/month-picker.md)
- [Calendar](https://gelatinui.com/components/calendar.md)
- [Date Picker](https://gelatinui.com/components/date-picker.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Arrow keys | Move one year, or one row. Past an edge the page turns. |
| Home, End | Go to the first or the last year of the page. |
| Page Up, Page Down | Go 12 years back or on. |
| Enter | Picks the focused year. |
