react-datepicker input width will not adjust to 100%
I had the same issue and solved it thanks to Rbar's answer.
Wrap your DatePicker component with a custom container. Then assign the width to that container and its children like below:
import "./customDatePickerWidth.css";
<div className="customDatePickerWidth">
<DatePicker dateFormat="dd/MM/yyyy" />
</div>
Inside the customDatePickerWidth.css:
.customDatePickerWidth,
.customDatePickerWidth > div.react-datepicker-wrapper,
.customDatePickerWidth > div > div.react-datepicker__input-container
.customDatePickerWidth > div > div.react-datepicker__input-container input {
width: 100%;
}
How can I reduce width and height of my dateTimePicker?
Override the CSS rules of react-datetime
like the following:
.rdtPicker {
width: 400px; //Change it your preferred width
}
.rdtPicker tr {
height: 50px; //Choose the height of each row so that the overall height will change
}
Here's a working pen.
I'm having trouble with react-datepicker position
I fixed it as react-popper will place the popover in the same constraints as the
parent div. For cases where the parent div is somehow constrained -- a
scrollable div -- the popper will appear inside the div and will be
constrained by it to.
In my case I wanted the popover to be unconstrained it's
parent. To fix this, I placed the popover in a container outside of
the constrained container.
import { Portal } from "react-overlays";
const CalendarContainer = ({ children }) => {
const el = document.getElementById("calendar-portal");
return <Portal container={el}>{children}</Portal>;
};
And added the popperContainer prop to the DatePicker like so:
<DatePicker
selected={startDate}
onChange={onChangeDatePickerStartDate}
dateFormat="yyyy-MM-dd"
className="text-center date-picker-reports"
showMonthDropdown
showYearDropdown
dropdownMode="select"
onChangeRaw={handleDateChangeRaw}
popperPlacement="top-start"
placeholderText="Choose a start date"
popperContainer={CalendarContainer}
/>
Final Result:
Related Topics
Transition Only for The Border on Hover, But Not for Background
CSS: Series of Floated Elements Without Wrapping But Rather Scrolling Horizontally
Detecting Printed Page Size with CSS Media Queries
Validating Check Boxes in HTML
Using CSS Modules in React How to Pass a Classname as a Prop to a Component
CSS3 Flexbox Full-Height App and Overflow
Bootstrap4 Make All Input-Group-Addons Same Width
Sharepoint 2013 Deleting Contents of <Style> in Embed Code When Saving
How to Center a Button in Material-Ui
Issue Making Bootstrap3 Icon Spin
Ems to Pixel Conversion - Why 62.5% and Not 6.25%
Navigation Tabs with Jquery Mobile Similar to Google Play Store
How to Render Segoe UI Font in Different Navigators and Os's
How to Stretch a Div to 100% Page Height
CSS Flex Box Layout: Full-Width Row and Columns
How to Use SASS to Properly Avoid Embedding Twitter Bootstrap Class Names on HTML