Skip to content
Protocore Design Systemv1.6.9

/// Inputs

YearPicker

Inline grid of years paged a decade at a time, with full arrow-key selection, returning the chosen year as a number.

import { YearPicker } from "@protocore/pds";
View as Markdown

Basics

Twelve years fill a 4×3 grid under a range header; the chevrons page the view by a decade. Selecting a year emits a number. Controllable via value / defaultValue / onValueChange plus a controllable pageStart.

2016–2027

Bounded range

Pass min / max to disable years outside the valid window — disabled cells stay keyboard-reachable but can't be selected.

2016–2027

When to use it

Use YearPicker when only the year matters — a founding year, a model year, a tax year. It shares its grid engine with MonthPicker. When a month within the year matters use MonthPicker; for a specific day use DatePicker or Calendar.

Usage

Do

  • Read the emitted `number` directly — the value is a plain year.
  • Set `min` / `max` to disable years outside the selectable window.
  • Set `defaultPageStart` to land the view near the likely choice.
  • Wrap it in a `Field` when it needs a visible label.

Don't

  • Don't use it when a month or day is part of the answer — step up to MonthPicker or Calendar.
  • Don't infer the choice from the visible page range — read `onValueChange`.
  • Don't hand it into a popover expecting a trigger; it renders inline.
  • Don't rely on colour alone — the selected cell also inverts its fill.

Accessibility

KeysAction
Arrow keysMove between year cells (clamped to the grid).
Home / EndJump to the first / last year on the page.
Enter / SpaceSelect the focused year.
  • The year cells form a `role="grid"` with `role="row"` groupings and roving tabindex, so only one cell is in the tab order.
  • Each cell carries an `aria-label` of its year and `aria-selected` when chosen.
  • The range header exposes labelled Previous / Next buttons and an `aria-live` range readout.

YearPicker props

PropTypeDefaultDescription
classNamestring
defaultPageStartnumberInitial first year of the visible page in uncontrolled mode.
defaultValuenumber | nullInitial selected year in uncontrolled mode.
maxnumberLatest selectable year (inclusive).
minnumberEarliest selectable year (inclusive).
onPageStartChange((pageStart: number) => void)Fires when the visible page changes.
onValueChange((value: number) => void)Fires with the chosen year.
pageStartnumberControlled first year of the visible page.
styleCSSProperties
valuenumber | nullControlled selected year.

Related

  • MonthPickerInline 12-month grid with a year header for navigation and full arrow-key selection, returning the first day of the chosen month.
  • DatePickerSunken field showing a formatted date that opens a Calendar in a raised overlay for point-and-click selection.
  • CalendarMonth-grid date picker with full keyboard navigation, single or range selection, and locale-aware labels.