YearPickerInput
Inline year, multiple years and years range picker
Source
LLM docs
Docs
Package
YearPicker props
YearPickerInput supports most of the YearPicker props.
Read through the YearPicker documentation to learn about all component features that are not listed on this page.
Usage
Multiple dates
Set type="multiple" to allow users to pick multiple dates:
Dates range
Set type="range" to allow users to pick a date range:
Open picker in modal
By default, YearPicker is rendered inside Popover.
You can change that to Modal by setting dropdownType="modal":
Value format
Use the valueFormat prop to change the dayjs format of the value label:
Value formatter
valueFormatter is a more powerful alternative to the valueFormat prop.
It allows formatting the value label with a custom function.
The function is the same for all component types (default, multiple and range)
– you need to perform additional checks inside the function to handle different types.
Example of using a custom formatter function with type="multiple":
Clearable
Set the clearable prop to display a clear button in the right section. Note that if you set the rightSection
prop, the clear button will not be displayed.
Clear section mode
The clearSectionMode prop determines how the clear button and rightSection are rendered:
'both'(default) – render both the clear button andrightSection'rightSection'– render only the user-suppliedrightSection, ignore clear button'clear'– render only the clear button, ignorerightSection
Disabled state
Min and max dates
minDate and maxDate props define the minimum and maximum dates that can be picked.
You can specify minDate and maxDate as Date objects:
Control props
getYearControlProps prop allows passing props to the control component based on the date.
It is useful for disabling specific dates or customising styles/className.
Year label format
yearsListFormat props allow changing the format of the year label in the years list.
It accepts a dayjs format string.
Decade label format
decadeLabelFormat prop allows changing the format of the decade label in the header.
It accepts a dayjs format string.
Input props
MonthPickerInput component supports Input and Input.Wrapper component features and all button element props. The MonthPickerInput documentation does not include all features supported by the component – see the Input documentation to learn about all available features.
With icon
Get element ref
Accessibility
If YearPickerInput is used without the label prop, it will not be announced properly by screen readers:
Set aria-label to make the input accessible. In this case the label will not be visible, but screen readers will announce it:
If the label prop is set, the input will be accessible and it is not required to set aria-label: