Skip to content

Commit 1d043c1

Browse files
committed
[DatePicker] Allow customizing icons mui#23673
1 parent e244c6e commit 1d043c1

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

packages/material-ui-lab/src/DayPicker/DayPicker.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ const DayPicker = React.forwardRef(function DayPicker<
189189
disablePast={disablePast}
190190
disableFuture={disableFuture}
191191
reduceAnimations={reduceAnimations}
192+
components={{
193+
headerDropdownIcon: <div>Hello</div>,
194+
}}
192195
/>
193196
<FadeTransitionGroup
194197
reduceAnimations={reduceAnimations}

packages/material-ui-lab/src/DayPicker/PickersCalendarHeader.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useUtils } from '../internal/pickers/hooks/useUtils';
1010
import FadeTransitionGroup from './PickersFadeTransitionGroup';
1111
import { DateValidationProps } from '../internal/pickers/date-utils';
1212
// tslint:disable-next-line no-relative-import-in-test
13-
import ArrowDropDownIcon from '../internal/svg-icons/ArrowDropDown';
13+
import ArrowDropDownIcon from '../internal/svg-icons/ArrowLeft';
1414
import ArrowSwitcher, {
1515
ExportedArrowSwitcherProps,
1616
} from '../internal/pickers/PickersArrowSwitcher';
@@ -20,6 +20,10 @@ import {
2020
} from '../internal/pickers/hooks/date-helpers-hooks';
2121
import { DatePickerView } from '../internal/pickers/typings/Views';
2222

23+
export interface ComponentsProps {
24+
headerDropdownIcon?: React.ReactNode;
25+
}
26+
2327
export type ExportedCalendarHeaderProps<TDate> = Pick<
2428
PickersCalendarHeaderProps<TDate>,
2529
| 'leftArrowIcon'
@@ -37,6 +41,7 @@ export interface PickersCalendarHeaderProps<TDate>
3741
openView: DatePickerView;
3842
views: DatePickerView[];
3943
currentMonth: TDate;
44+
components?: ComponentsProps;
4045
/**
4146
* Get aria-label text for switching between views button.
4247
*/
@@ -103,6 +108,7 @@ function PickersCalendarHeader<TDate>(
103108
onViewChange,
104109
classes,
105110
currentMonth: month,
111+
components = {},
106112
disableFuture,
107113
disablePast,
108114
getViewSwitchingButtonText = getSwitchingViewAriaText,
@@ -142,6 +148,8 @@ function PickersCalendarHeader<TDate>(
142148
}
143149
};
144150

151+
const { headerDropdownIcon } = components;
152+
145153
return (
146154
<React.Fragment>
147155
<div className={classes.root}>
@@ -181,11 +189,13 @@ function PickersCalendarHeader<TDate>(
181189
className={classes.yearSelectionSwitcher}
182190
aria-label={getViewSwitchingButtonText(currentView)}
183191
>
184-
<ArrowDropDownIcon
185-
className={clsx(classes.switchViewDropdown, {
186-
[classes.switchViewDropdownDown]: currentView === 'year',
187-
})}
188-
/>
192+
{headerDropdownIcon || (
193+
<ArrowDropDownIcon
194+
className={clsx(classes.switchViewDropdown, {
195+
[classes.switchViewDropdownDown]: currentView === 'year',
196+
})}
197+
/>
198+
)}
189199
</IconButton>
190200
)}
191201
</div>

0 commit comments

Comments
 (0)