apps/mantine.dev/src/pages/dates/year-picker-input.mdx
import { YearPickerInputDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx';
export default Layout(MDX_DATA.YearPickerInput);
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.
Set type="multiple" to allow users to pick multiple dates:
Set type="range" to allow users to pick a date range:
Use the presets prop to add custom year presets. Presets are displayed next to the calendar:
To use presets with type="range", define the value as a tuple of two dates:
By default, YearPicker is rendered inside Popover.
You can change that to Modal by setting dropdownType="modal":
Use the valueFormat prop to change the dayjs format of the value label:
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":
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.
minDate and maxDate props define the minimum and maximum dates that can be picked.
You can specify minDate and maxDate as Date objects:
getYearControlProps prop allows passing props to the control component based on the date.
It is useful for disabling specific dates or customising styles/className.
yearsListFormat props allow changing the format of the year label in the years list.
It accepts a dayjs format string.
decadeLabelFormat prop allows changing the format of the decade label in the header.
It accepts a dayjs format string.
<GetElementRef component="YearPickerInput" refType="button" package="@mantine/dates" />
<InputAccessibility component="YearPickerInput" packageName="@mantine/dates" />