-
Notifications
You must be signed in to change notification settings - Fork 408
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
Support Bootstrap 5 #622
Comments
|
|
Bootstrap 5 is now released. Any ETA on when support could be expected? |
Not exactly sure it's a Bootstrap5 exclusive issue, but I'm using it with the 2.0.0-beta.2 react-bootstrap. Elements with class |
Support for @filipkis: I don't have a timeline on when full, out of the box support will happen. I'll try to add things incrementally, but the close button and floating label changes are both non-trivial. |
BS 5.0.2 | RBT 5.2.0 | Remove button styling is missing: https://prnt.sc/1d683mt @ericgio |
Any ETA for this? On initial testing it seems like the loading indicator shows text+the spinning animation and the close/delete button seem to be missing (as it shows text only too) |
There's been quite a change between BS4 and BS5 in regard how the "close" icon/button is implemented. In BS4, it was using a
And in BS5, this changed to just using a
And it looks like the current v5.2.0 lib code is still generating the underlying component code to be compatible to BS4, which includes the child However, I solved this in our project, where we use BS5, by adding this SCSS snippet. It's overwriting a the
I didn't have enough time to think of an elegant and simple solution from the library code point of view, to keep both BS4 and BS5 compatibility. |
That sounds right. When BS4 came out I added a separate CSS file with BS4 overrides that consumers of the library needed to import as well as the main file. This is most likely the approach I'll need to take for BS5 as well. The switch to using a background image for the close button is pretty unfortunate from a flexibility point of view, since it makes it much more difficult to customize, eg: applying a different color. Still no set timeline for complete out of the box support, but I'd like to include it with v6.0, currently in alpha. |
This comment has been minimized.
This comment has been minimized.
In case someone wants an alternative solution to the SCSS fix, I believe this fix works in plain CSS: .rbt-token .rbt-token-remove-button {
margin-right: -10px;
}
.rbt-input-wrapper div:nth-child(n+2) {
padding-left: 10px;
} It's far from good, but it does the job for my use case. We basically pad the button 10px to the right and adjust everything (cursor position, etc) accordingly -- but only if there is more than one item actually present in the div. |
Something quick and dirty:
|
The BS5 clear button is now supported as of v6.0.0-alpha.7. Along with the existing |
As of v6.0.0-alpha.8 you can use floating labels with the typeahead as follows: <Typeahead
...
renderInput={({ inputRef, referenceElementRef, ...inputProps }) => (
<Hint>
<FloatingLabel controlId="name-input" label="Name">
<Form.Control
{...inputProps}
ref={(node) => {
inputRef(node);
referenceElementRef(node);
}}
/>
</FloatingLabel>
</Hint>
)}
/> |
Bootstrap v5 officially supported as of v6.0.0 |
I tried this implementation provided and this does work. Thank you! However I feel like this is a rather ugly implementation. Couldn't some behavior like this be provided like a property or something, so maybe we could open a feature request? Also I don't really understand what the |
I agree that customizing the input this way is a bit more difficult for the developer than simply setting some prop to |
@ericgio thank you so much for the fast reply! Generally speaking I can totally understand! Though from my perspective as one of those using the floating labels it's rather not so satisfying hah. Though what to support and what not is in the end up to you and I totally do understand your argumentation. Talking about the second part of my comment (which partly got lost in Github formatting) could you give some information why the Also I guess there is no chance of implementing the floating label for a multi input? :) |
I was trying to create a custom implementation for the floatingLabel on a multi typeahead, though, it does not work as expected, not sure what I am doing wrong, though I cannot see any of the selected options as the selected is always undefined.
Not yet sure where exactly to place the Token for the optimal appearance, though I cannot see any Token in neither the dom nor the props or anything. Also I noticed the className provided by |
The multi-input unfortunately does not play well with Bootstrap's floating label due to the way it uses CSS selectors.
It looks like you're trying to de-structure
That's right. The multi-select input component accepts both a |
Hi, If that can help anyone: here is the css styles that I use to have RBT working with Floating Label: /**
* Extend Typeahead to support floating labels.
*/
.form-floating > .rbt .form-control {
height: calc(3.5rem + calc(var(--bs-border-width) * 2));
min-height: calc(3.5rem + calc(var(--bs-border-width) * 2));
line-height: 1.25;
}
.form-floating > .rbt .form-control:focus,
.form-floating > .rbt .form-control:not(:placeholder-shown) {
padding-top: 1.625rem;
padding-bottom: 0.625rem;
}
.form-floating > .rbt:has(.form-control:focus) ~ label,
.form-floating > .rbt:has(.form-control:not(:placeholder-shown)) ~ label {
color: rgba(var(--bs-body-color-rgb), 0.65);
transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}
.form-floating > .rbt:has(.form-control:not(:focus):placeholder-shown) ~ label {
display: none;
} Then my JSX looks as simple as expected: <Form.FloatingLabel controlId="floatingSelect1" label="Floating label">
<Typeahead options={options} clearButton={true} allowNew={true} placeholder="Choose an option..." />
</Form.FloatingLabel> Testing with
|
Bootstrap 5 is currently in beta, so I'm creating this issue to track the changes this library will need to make to support the new version out of the box. Please comment if you come across anything not working.
ClearButton
classname to includebtn-close
(BS5 Close Button component)sr-only
classname tovisually-hidden
(Helpers)As a general workaround, the typeahead's render props and child render function can be used to customize individual components in a way that better supports BS5.
The text was updated successfully, but these errors were encountered: