You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add monthHeaderPosition prop to control month header placement
Add new monthHeaderPosition prop that allows positioning the month header
in three locations: top (default), middle (between day names and calendar),
or bottom (at calendar bottom). This feature provides greater flexibility
for calendar layout customization.
Changes:
- Add monthHeaderPosition prop to DatePicker, PopperComponent, and Calendar components
- Implement conditional rendering logic in Calendar.renderDefaultHeader()
- Add monthHeader and monthFooter props to Month component for content injection
- Add CSS classes for middle/bottom header positions with proper triangle styling
- Add .react-datepicker__header-wrapper for navigation button positioning
- Include comprehensive test coverage for new functionality
- Add documentation and live example to docs-site
Technical implementation:
- PropperComponent applies CSS classes based on header position
- Calendar wraps header with navigation buttons for middle/bottom positions
- Month component renders header/footer content at appropriate locations
- SCSS handles triangle colors and navigation button positioning per position
Test coverage includes unit tests for all three positions across components:
calendar_test.test.tsx, month_header_position.test.tsx, and
popper_component.test.tsx. All 167 tests passing with maintained coverage.
The `monthHeaderPosition` prop allows you to control where the month header (e.g., "December 2025") is displayed in the calendar. By default, it appears in the standard header section above the day names. You can reposition the header to appear between the day names and calendar days ("middle") or at the bottom of the calendar ("bottom").
6
+
7
+
## Type
8
+
9
+
```typescript
10
+
monthHeaderPosition?:"top"|"middle"|"bottom";
11
+
```
12
+
13
+
## Values
14
+
15
+
-`"top"` (or undefined) - Month header appears in the standard position at the top of the calendar (default)
16
+
-`"middle"` - Month header appears between day names and calendar days
17
+
-`"bottom"` - Month header appears at the bottom of the calendar
18
+
19
+
## Usage
20
+
21
+
```tsx
22
+
importReact, { useState } from"react";
23
+
importDatePickerfrom"react-datepicker";
24
+
25
+
// Example 1: Header in the middle (between day names and days)
- When `monthHeaderPosition` is set to `"middle"` or `"bottom"`, the month header (including navigation buttons and dropdowns) is removed from the default header section
50
+
- Works with multiple months (`monthsShown` prop) - each month's header will be positioned accordingly
51
+
- Navigation buttons are included and properly positioned in all three position options
0 commit comments