Yearpicker overview
TailNG Yearpicker is a year-only selection surface built on the shared datepicker component. It opens directly on the year grid, emits a plain number on selection, and closes automatically — making it ideal for fiscal year fields, filter panels, and settings where month and day are not relevant.
Simple sample
Compare the stock wrapper in its default plain-CSS presentation and in a theme-aware Tailwind shell.
Simple sample (Plain-CSS)
Simple sample (Tailwind CSS)
Import
Add TngYearpickerComponent to your component's imports array.
Wrapper import
import { TngYearpickerComponent } from '@tailng-ui/components';
Quick start
Default wrapper usage
<tng-yearpicker
[defaultValue]="2024"
[minYear]="2000"
[maxYear]="2030"
placeholder="YYYY"
></tng-yearpicker>
How it works
The yearpicker wraps the shared datepicker with a custom adapter that formats dates as plain four-digit years and parses YYYY strings back into a Date. The fixedMonth and fixedDay inputs pin the internal date to a consistent anchor — useful when the downstream system expects a full date but only cares about the year. On open, the popup jumps directly to the year grid; when the user picks a year, the popup closes and valueChange emits the number.
Behavior baseline
- Supports both uncontrolled (
defaultValue) and controlled (value) selection modes. - The text input accepts a four-digit
YYYYstring; invalid input is discarded. minYearandmaxYearconstrain the year grid and keyboard navigation.- The popup opens directly on the year grid and closes automatically after selection.
yearPageSizecontrols how many years appear per page (default 24).- Integrates with
tng-form-fieldvia theTNG_FORM_FIELD_CONTROLtoken. - Theme changes flow through semantic tokens so the field and portaled overlay stay in sync.