Skip to content
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

How to customize react-datepicker-wrapper class #2099

Open
chupee120 opened this issue Mar 25, 2020 · 21 comments
Open

How to customize react-datepicker-wrapper class #2099

chupee120 opened this issue Mar 25, 2020 · 21 comments

Comments

@chupee120
Copy link

chupee120 commented Mar 25, 2020

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,

@cordero67
Copy link

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

@danielmdebrito
Copy link

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

@Cordazar
Copy link

Cordazar commented Jun 3, 2020

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

@BrandonMathis
Copy link

BrandonMathis commented Jul 6, 2020

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.

@wude935
Copy link

wude935 commented Aug 26, 2020

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.

@jaypeetancero
Copy link

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

@sonny89
Copy link

sonny89 commented Oct 6, 2020

Try with wrapperClassName property:

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

.datePicker {
  width: 100%;
}

@rosghub
Copy link

rosghub commented Oct 22, 2020

@sonny89 confirming this works great

@isaacminogue
Copy link

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

@dexkode4
Copy link

awesome , very helpful

@Akius1
Copy link

Akius1 commented May 11, 2021

@sonny89 Thanks a bunch. Very helpful

@marwajomaa
Copy link

wrapperClassName="datePicker"

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

@undefineq
Copy link

undefineq commented Jun 22, 2021

wrapperClassName="datePicker"

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

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

@marwajomaa
Copy link

marwajomaa commented Jun 22, 2021 via email

@No-you-are-not
Copy link

No-you-are-not commented Dec 2, 2021

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

@ismatim
Copy link

ismatim commented Jan 6, 2022

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)

@Ofer-Gal
Copy link

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% 😥

@trunglt-2769
Copy link

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

@afif14
Copy link

afif14 commented Jan 20, 2023

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

@Yanger-Rai
Copy link

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

@rever96
Copy link

rever96 commented Aug 18, 2023

Try with wrapperClassName property:

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

This issue should be closed with this reply

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

No branches or pull requests