Skip to content

Date titles #3598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PMLP-novo opened this issue May 17, 2022 · 4 comments
Closed

Date titles #3598

PMLP-novo opened this issue May 17, 2022 · 4 comments
Labels

Comments

@PMLP-novo
Copy link

PMLP-novo commented May 17, 2022

Is your feature request related to a problem? Please describe.
I want to communicate to my users why a day is highlighted or not highlighted

Describe the solution you'd like
I would love to be able to give a dateTitle function that can generate a title for each day where it is relevant. Such that the users easily can hover and see extra info.

() => {
  const [startDate, setStartDate] = useState(new Date());
  const highlightDates=[subDays(new Date(), 7), addDays(new Date(), 7)] 
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      highlightDates={highlightDates}
      dateTitle={(date)=>highlightDates.includes(date)?"Business logic"// Write some business logic telling the users why the specify day is highlighted
:null}
    />
  );
};
@PMLP-novo PMLP-novo changed the title Date titles in selector Date titles May 17, 2022
@shreekeshmurkar
Copy link
Contributor

shreekeshmurkar commented Jun 12, 2022

@PMLP-novo
Why can't this be solved using renderDayContents property ?
Try following code.

() => {
  const [startDate, setStartDate] = useState(new Date());
  const highlightDates= [subDays(new Date(), 7), addDays(new Date(), 7)];
  const highlightedDays = highlightDates.map(d => d.getDate()); 
 
  const renderDayContents = (day, date) => {
    const tooltipText = "Business logic";
    if (highlightedDays.includes(day)) {
        return <span title={tooltipText}>{getDate(date)}</span>;
    } else {
       return <span>{getDate(date)}</span>;
    }
    
  };
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      highlightDates={highlightDates}
      renderDayContents={renderDayContents}
    />
  );
};

@jees47
Copy link

jees47 commented Mar 31, 2023

is getDate inbuild function?, if not can you show me how its done also

Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jun 16, 2024
Copy link

github-actions bot commented May 4, 2025

This issue was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants