react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

calendarClassName doesn't work

Open han-yan-ds opened this issue 3 years ago • 8 comments

Describe the bug I can't style the calendar using calendarClassName like the example on https://reactdatepicker.com/, "Custom calendar class name"... there are also some other ____ClassName props that don't work either.

To Reproduce Steps to reproduce the behavior:

This is my code:

    import React, { useState } from "react";
    import DatePicker from "react-datepicker";
    import "react-datepicker/dist/react-datepicker.css";
    
    const DatePickerTest = () => {
      const [startDate, setStartDate] = useState(new Date());
     
      return (
        <DatePicker
          selected={startDate}
          onChange={(date) => setStartDate(date)}
          className="bg-tableDark text-white" // works
          calendarClassName="bg-blue" // doesn't work
          timeClassName={() => "bg-blue"}
          popperClassName="bg-lightBlue" // works
          wrapperClassName={() => "bg-blue"} // doesn't work
          weekDayClassName={() => "bg-lime"} // works
          dayClassName={() => "bg-darkGreen"} // works
        />
      );
    };
    
    export default DatePickerTest;`

And this is what it looks like: image

Expected behavior I expect calendarClassName to work like it does on the website.

han-yan-ds avatar Mar 23 '21 21:03 han-yan-ds

I just looked further... many of the built-in styles (in /dist/react-datepicker.css) are overwriting the styles passed in as calendarClassName and wrapperClassName.

han-yan-ds avatar Mar 24 '21 15:03 han-yan-ds

I have the same problem, did you found out the solution? I made my component in the Storybook and on Storybook looks good, but when I apply the component somewhere it does exactly what you say the /dist/react-datepicker.css overwrite any className

guifeliper avatar Apr 14 '21 06:04 guifeliper

@guifeliper My team ended up using React-Dates

han-yan-ds avatar Apr 14 '21 15:04 han-yan-ds

I also need time, I cannot do that move. I try to squeeze some time and fix myself.

guifeliper avatar Apr 15 '21 05:04 guifeliper

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 03 '22 05:03 stale[bot]

Issue still persists

ghost avatar Mar 15 '22 15:03 ghost

Still an issue

jasenc89 avatar Jun 01 '22 13:06 jasenc89

@jasenc89 @karolis-cekaitis @guifeliper Add !important to your styles to stop them being overwritten by the "react-datepicker/dist/react-datepicker.css" file.

CDL-lawebb avatar Jun 10 '22 10:06 CDL-lawebb

still an issue

CaneteJoash avatar Oct 18 '22 05:10 CaneteJoash

still issue

matiasmoneghessi avatar May 05 '23 17:05 matiasmoneghessi

still issue

comalex avatar Aug 22 '23 08:08 comalex