You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using DatePicker variant "single with calendar". I noticed that the width of the component is fixed to 18rem, matching the calendar popup width. My inspection shows this predefined CSS.
But my forms have dynamic input widths, so I made the DatePicker also with a dynamic width. The problem now is, that the calendar is positioned left, away from the calendar icon.
I would expect the calendar to remain right, where the calendar icon is.
This flatpickr calendar is somehow positioned outsite of the react app, appended in the <body>. Its CSS has some magic left positioning
// in codesandbox where no sorrounding padding exists
element.style {
top: 66px;
left: 0px;
right: auto;
}
// in storybook where a padding around a story exists
element.style {
top: 262px;
left: 42.5px;
right: auto;
}
It is anyways left aligned to the input field.
Is there any way to define the position? In the source code, neither in DatePicker nor in DatePickerInput I find something with position.
Hi @FabianPiconeDev, this relates to the fluid inputs proposal that is approved but still a work in progress. The calendar remaining left aligned on a fluid width input is to spec based on the images in the linked issue.
Is there any way to define the position?
The positioning is determined by the appendToPlugin that is passed to flatpickr. To modify positioning of the calendar you can target the .flatpickr-calendar class with custom CSS, or another potential route would be to customize the dom element that the flatpickr is inserted into via the appendTo prop.
Let me know if this is helpful - I'm going to close this for now, but can always reopen if there's a continued issue. Thanks!
What package(s) are you using?
carbon-components
10.35.0carbon-components-react
7.35.0Detailed description
I am using DatePicker variant "single with calendar". I noticed that the width of the component is fixed to
18rem
, matching the calendar popup width. My inspection shows this predefined CSS.But my forms have dynamic input widths, so I made the DatePicker also with a dynamic width. The problem now is, that the calendar is positioned left, away from the calendar icon.
I would expect the calendar to remain right, where the calendar icon is.
This flatpickr calendar is somehow positioned outsite of the react app, appended in the
<body>
. Its CSS has some magic left positioningIt is anyways left aligned to the input field.
Is there any way to define the position? In the source code, neither in DatePicker nor in DatePickerInput I find something with
position
.Steps to reproduce the issue
The text was updated successfully, but these errors were encountered: