DayContent missing from CustomComponents #2406
-
IssueWhen configuring the DayPicker without a CodeList of custom components: https://github.com/gpbl/react-day-picker/tree/main/src/components Types: react-day-picker/src/types/shared.ts Lines 47 to 92 in 095d40c It is also referenced in the QuestionCan If not, is there an example how to set up a custom |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@hrypkema-amplify Yes, the If you want to customize the content of the day when is not the <DayPicker
formatters={{
formatDay: (day) => String(day.getDate())
}}
/> Thanks for reporting that comment in the documentation. I'm going to remove it... |
Beta Was this translation helpful? Give feedback.
-
@gpbl ah I see, thanks! the use case I needed was rather to add a wrapping span element around in case its useful, the solution I ended up with was to create a custom const CustomDay = ({ day, modifiers, children, mode, ...props }) => {
const isInteractive = mode !== undefined;
return (
<td {...props}>
{!isInteractive && (
<span className="rdp-day_content">
{children}
</span>
)}
{isInteractive && children}
</td>
);
}; And customizing the DayPicker with it: import CustomDay from './CustomDay.tsx';
...
return (
<DayPicker
components={{
Day: props => CustomDay({ mode, ...props }),
}}
/>
); |
Beta Was this translation helpful? Give feedback.
@hrypkema-amplify Yes, the
DayContent
component has been removed in v9.If you want to customize the content of the day when is not the
DayButton
component, pass a custom formatDay formatter:Thanks for reporting that comment in the documentation. I'm going to remove it...