Bootstrap input-group CSS alignment
See original GitHub issuev.0.27.0 React v.15.0.1
I’m including the styles as noted in the docs:
require('react-datepicker/dist/react-datepicker.css');
There is a considerable disparity between the addon and the input style/alignment:
markup:
<div className="input-group">
<span className="input-group-addon">
<i className="fa fa-calendar"></i>
</span>
<DatePicker
selected={this.state.startDate}
onChange={this.handleDateChange.bind(null, 'startDate')}
placeholderText="Start Date …"
className="form-control"/>
</div>
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to align inputs in bootstrap form with input-group-addons?
I find that I needed to include: float: left as well. So, the css is: .input-group[class*="col-"] { float: left; padding-right: 15px; ...
Read more >Input group - Bootstrap
Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs....
Read more >Bootstrap CSS class: input-group - Shuffle
Bootstrap CSS class input-group with source code and live preview. You can copy the example and paste it into your project or use...
Read more >Alignment issue with input-group-btn #24 - GitHub
... to use an input-group-btn with Typeahead, the button does not align ... using the latest version of Bootstrap, Typeahead, and this CSS....
Read more >Center Bootstrap 4 Input Group - 2 ways on Codeply
Use flexbox or mx-auto to center an input group in Bootstrap 4 Codeply example. ... <div class="form-row justify-content-center">. <div class="form-group ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have the same problem with this.
A temporary hacky workaround I have found is to add this scss:
This works fine for regular form elements however when you use inline form elements, that is where the hacky part come into play. When using inline form elements, the height of the
react-datepicker__input-container
becomes messed up and does not reflect the height of the elements within. In order to work around that, you can use thepopoverTargetOffset
property ofreact-datepicker
to align the date picker itself properly.@martijnrusschen I would be in favor of removing the clear functionality because as @rafeememon said, that is not very difficult functionality to implement manually and it would make this component more flexible to work with. While my hacky solution works, I would not want it to be a long term solution as it would be very prone to breaking as styles are tweaked.
I use a
customInput
that uses http://react-bootstrap.github.io/ for this use case:and then
Maybe some custom input implementations could be provided with
react-datepicker
, this one would need a dependency on react-bootstrap though.