feat: Add monthHeaderPosition prop for flexible calendar header placement #6092
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new
monthHeaderPositionprop that allows developers to control the placement of the month header within the calendar. The header can now be positioned at the top (default), middle (between day names and calendar days), or bottom of the calendar.Motivation
Provides greater flexibility for calendar layout customization, enabling developers to create more diverse calendar designs while maintaining all existing functionality.
Changes
Component Updates
monthHeaderPositionprop and passed it toPopperComponentmonthHeaderPositionand applies corresponding CSS classesmonthHeaderandmonthFooterprops for content injectionStyling
.react-datepicker-popper--header-middleand.react-datepicker-popper--header-bottomclasses.react-datepicker__header-wrapperfor proper navigation button positioning.react-datepicker__header--middleand.react-datepicker__header--bottommodifier classesDocumentation
docs/month_header_position.mdTesting
month_header_position.test.tsx(6 tests)popper_component.test.tsxwith 4 new tests for CSS class applicationcalendar_test.test.tsxwith 3 new tests for navigation button positioningAPI
Usage Example
Breaking Changes
None. This is a fully backward-compatible addition with
topas the default value.Screenshots/Demo
The interactive example can be viewed in the docs-site, allowing users to toggle between all three header positions.