WeekPickerInput
Week, multiple weeks and weeks range picker input
Source
LLM docs
Docs
Package
WeekPicker props
WeekPickerInput supports most of the WeekPicker props.
Read through the WeekPicker documentation to learn about all component features that are not listed on this page.
Usage
The value is a date string in YYYY-MM-DD format pointing to the first day of the selected week.
The input label displays the week as a range of its first and last day:
Multiple weeks
Set type="multiple" to allow users to pick multiple weeks:
Weeks range
Set type="range" to allow users to pick a weeks range. The label displays the range from the first day of the
first week to the last day of the last week:
First day of week
firstDayOfWeek changes the calendar layout, the emitted value and the label:
Presets
Use the presets prop to add custom week presets. Presets are displayed next to the calendar.
Any date inside the week can be used as a preset value:
To use presets with type="range", define the value as a tuple of two dates:
Open picker in modal
By default, WeekPicker is rendered inside Popover.
You can change that to Modal by setting dropdownType="modal":
Value format
valueFormat is a dayjs format applied to both the first and the last day
of the week. The default value is MMM D, YYYY:
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":
getWeekFormatter(firstDayOfWeek) exported from @mantine/dates returns the default formatter.
Use it in your own formatter, for example to add the ISO week number:
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:
Week controls
Week numbers are the only focusable elements of the calendar, days can be clicked with the mouse only.
Use getWeekControlProps to change aria-label or disable specific weeks,
see WeekPicker documentation for details.
Max level
maxLevel prop allows to set the maximum level that can be reached by clicking on the label in the header.
Input props
WeekPickerInput component supports Input and Input.Wrapper component features and all button element props. The WeekPickerInput documentation does not include all features supported by the component – see the Input documentation to learn about all available features.
With icon
Native level select
Get element ref
Accessibility
If WeekPickerInput 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: