Skip to content

Add Custom Text on Single Day (v8) #1418

Answered by gpbl
brennondenny asked this question in Support
Discussion options

You must be logged in to vote

@brennondenny have a look to this example:
https://codesandbox.io/s/sandpack-project-forked-huni2h

You can use the a Day custom component to add a content above the DayContent.

import React from "react";
import { Day, DayProps, DayPicker, useActiveModifiers } from "react-day-picker";

function DayWithText(props) {
  const activeModifiers = useActiveModifiers(props.date, props.displayMonth);
  return (
    <span>
      <Day {...props} />
      {activeModifiers.today && "Today!"}
    </span>
  );
}

export default function App() {
  return <DayPicker components={{ Day: DayWithText }} />;
}

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@ammarjmhor10
Comment options

@gpbl
Comment options

Answer selected by gpbl
Comment options

You must be logged in to vote
2 replies
@gpbl
Comment options

@brennondenny
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants