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

How to customize react-datepicker-wrapper class

Open chupee120 opened this issue 4 years ago • 18 comments

Hello,

I'm not able to set width of datePicker to 100% .

The customization is applied to react-datepicker__input-container and input but not react-datepicker-wrapper.

import "./DatePickerInput.css";

<div className={style.containerDatePicker}>
   <DatePicker className={style.datePicker} dateFormat="dd/MM/yyyy" />
</div>
.containerDatePicker, 
.containerDatePicker> div.react-datepicker-wrapper, 
.containerDatePicker> div > div.react-datepicker__input-container
.containerDatePicker> div > div.react-datepicker__input-container input {
   width: 100% !important;
}

.datePicker {
  width: 100% !important;
}

also try this without success:

.react-datepicker__input-container {
    display: block !important;
}

.react-datepicker-wrapper {
    width: 100% !important;
}

.datePicker {
  width: 100% !important;
}

Version is "react-datepicker": "^2.14.1"

Regards,

chupee120 avatar Mar 25 '20 18:03 chupee120

I'm having the same problem. Bumping this issue.

cordero67 avatar Apr 16 '20 23:04 cordero67

The solution can be found here: https://stackoverflow.com/questions/55794770/how-can-i-style-react-datepicker

danielmdebrito avatar Apr 20 '20 18:04 danielmdebrito

But this should be a simple option or className set from the component, instead of adding global css rules to override it.

Cordazar avatar Jun 03 '20 15:06 Cordazar

I agree with @Cordazar. Overriding styles with CSS would not be ideal because my changes would impact every instance of the datepicker in my application.

Would be nice if we could pass a prop to at least append additional classes to the wrapper div.

BrandonMathis avatar Jul 06 '20 18:07 BrandonMathis

I'm having the same issue. The react-datepicker-class should be exposed via props so that styling is possible without editing all global instances, IMO.

wude935 avatar Aug 26 '20 04:08 wude935

I hope this concern would be resolve I don't want to create global style just for that.

jaypeetancero avatar Aug 27 '20 08:08 jaypeetancero

Try with wrapperClassName property:

<DatePicker wrapperClassName="datePicker" dateFormat="dd/MM/yyyy" />

.datePicker {
  width: 100%;
}

sonny89 avatar Oct 06 '20 11:10 sonny89

@sonny89 confirming this works great

rosghub avatar Oct 22 '20 18:10 rosghub

Whilst the above styles the input itself, if you want to style the calendar component, I've had success with <DatePicker calendarClassName={/* conditions */}></DatePicker> with conditional statements to show different classes based on values in the parent component

isaacminogue avatar Oct 27 '20 00:10 isaacminogue

awesome , very helpful

dexkode4 avatar Jan 24 '21 09:01 dexkode4

@sonny89 Thanks a bunch. Very helpful

Akius1 avatar May 11 '21 13:05 Akius1

wrapperClassName="datePicker"

how to use this with next.js it's not working?!!

marwajomaa avatar Jun 22 '21 18:06 marwajomaa

wrapperClassName="datePicker"

how to use this with next.js it's not working?!!

import styles from "./styles.module.scss"; wrapperClassName={styles.datePicker}

undefineq avatar Jun 22 '21 18:06 undefineq

Yes, I did that but not working!!!

On Tue, 22 Jun 2021, 21:54 Sulkhan, @.***> wrote:

wrapperClassName="datePicker"

how to use this with next.js it's not working?!!

import styles from "./styles.module.scss"; wrapperClassName={styles.datePicker}

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Hacker0x01/react-datepicker/issues/2099#issuecomment-866247631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIFJ3M4B5G6CF7ZRV2ZQVVLTUDL43ANCNFSM4LTVMLIQ .

marwajomaa avatar Jun 22 '21 19:06 marwajomaa

i have the same issue, when im trying to style the calendar component and not input. Nothing works for me, not calendarClassName, not wrapperClassName, not even putting datepicker inside of another div. The only way that i was able to change styles is changing them by tags like this: .wrapper div{ border: none; background-color: var(--base-white); } but that is just too global obviously


okey so i found the way to solve my issue, the reason i couldn't style the calendar is because we use module styles and i tried to overrite styles in module.scss, but i just had to create simle scss file and than import it directly to my component... yep

No-you-are-not avatar Dec 02 '21 09:12 No-you-are-not

wrapperClassName="datePicker"

how to use this with next.js it's not working?!!

import styles from "./styles.module.scss"; wrapperClassName={styles.datePicker}

wrapperClassName="datePicker"

how to use this with next.js it's not working?!!

There is no straight way to make it work with cssmodules & nextjs because it is needed to set each class with each element (inside datapicker). (as far I could see)

ismatim avatar Jan 06 '22 12:01 ismatim

The 100% of the datepicker is not the same of other control in my page image

I tried all sorts of ways. The closest to other controls 100% is 99% 😥

Ofer-Gal avatar Jan 25 '22 14:01 Ofer-Gal

The 100% of the datepicker is not the same of other control in my page image

I tried all sorts of ways. The closest to other controls 100% is 99% 😥

Try adding props box-sizing: border-box; to input element of React DatePicker

trunglt-2769 avatar May 25 '22 03:05 trunglt-2769

There is no straight way to make it work with cssmodules & nextjs because it is needed to set each class with each element (inside datapicker). (as far I could see)

and how to make it work in next js, i have the same issue

afif14 avatar Jan 20 '23 02:01 afif14

For Next.js

If you are using shadcn UI. Go into calendar component and remove "flex" from row and head_row. Works perfectly. Refer the screenshot below. Haven't tried directly in day picker, maybe someone do it.

Screenshot 2023-08-01 at 1 47 40 AM

Yanger-Rai avatar Jul 31 '23 20:07 Yanger-Rai

Try with wrapperClassName property:

<DatePicker wrapperClassName="datePicker" dateFormat="dd/MM/yyyy" />

This issue should be closed with this reply

rever96 avatar Aug 18 '23 08:08 rever96