Skip to content

Is there a way to remove year in header title #1842

Answered by gpbl
isaacdarcilla asked this question in Support
Discussion options

You must be logged in to vote

@isaacdarcilla yes, use a formatCaption formatter:

https://codesandbox.io/s/pensive-poitras-5dn8yg?file=/App.tsx

import { DateFormatter, DayPicker } from "react-day-picker";

import { format } from "date-fns";

const formatCaption: DateFormatter = (month, options) => {
  return format(month, "LLLL", options);
};

function App() {
  return <DayPicker formatters={{ formatCaption }} />;
}

(Consider hiding the year is not a good practice for birthday dates: https://www.smashingmagazine.com/2021/05/frustrating-design-patterns-birthday-picker/)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gpbl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants