React-Bootstrap v2 and Bootstrap CSS major-version pairing: what is actually supported?
0 reputation · 05 Oct 2021, 02:13 UTC
0 reputation · 05 Oct 2021, 02:13 UTC
React-Bootstrap does not ship Bootstrap CSS, so the application must include a compatible stylesheet separately. I am planning a migration from React-Bootstrap v1 (Bootstrap 4) to v2 (Bootstrap 5) and need to pin down the exact compatibility contract before touching component code.
The uncertainty is around the boundaries of that contract. The v2 line is documented as targeting Bootstrap 5, but it is unclear whether compatibility is tracked per major version only, or whether specific Bootstrap 5 minor releases are required for certain components. There is also the open question of how the project handles newer Bootstrap majors: whether support lands in the mainline package or in a parallel release line, which affects upgrade timing.
A second constraint is that Bootstrap 5 renamed data attributes and dropped jQuery, so markup and prop expectations from v1 do not carry over unchanged.
React-Bootstrap v2 targets Bootstrap 5, full stop. The authoritative declaration is the peerDependencies entry in the published package, which requires bootstrap@^5.0.0; the documentation restates the same contract. Mixing v2 with Bootstrap 4 CSS is not a supported configuration, and Modal, Tooltip, and Dropdown are the components where a mismatch surfaces first. A hard cutover of the stylesheet — not a gradual CSS migration — is the realistic path.
Two places, and they should agree:
npm view react-bootstrap@2 peerDependencies\n# or, for the installed copy:\nnode -p \"require('react-bootstrap/package.json').peerDependencies\"The ^5.0.0 range means any Bootstrap 5 minor release satisfies the constraint. Compatibility is tracked per major version; there is no per-minor requirement matrix. That said, Bootstrap minor releases occasionally adjust spacing or class details, so pin an exact Bootstrap version in your own package.json rather than floating on the caret range — the library does not formally test every minor combination.
react-bootstrap package, not a parallel package name — so upgrade timing is gated on a React-Bootstrap major release, which you should confirm against the project's release notes when the time comes rather than assuming day-one support.React-Bootstrap renders markup built for Bootstrap 5's class and attribute conventions. Bootstrap 5 renamed its data attributes (data-toggle → data-bs-toggle), dropped jQuery, and reworked utilities (e.g., ml-*/mr-* → ms-*/me-*). Serving Bootstrap 4 CSS under v2 components doesn't produce a clean failure — some elements render roughly correctly, which is worse, because spacing, alignment, and interactive states silently degrade. Treat the stylesheet swap as atomic with the package upgrade: bump react-bootstrap and bootstrap together, replace the CSS import, and audit any hand-written markup or third-party plugins that still emit Bootstrap 4 attributes.
Modal, Tooltip, and Dropdown are the sensitive trio because they depend on positioned overlays, Bootstrap-5-specific classes (.modal-dialog, .dropdown-menu, .tooltip), and Popper-driven behavior. Build one smoke-test page rendering all three, then check the DOM:
data-bs-dismiss.If any of these render unstyled or mispositioned, the stylesheet being served is the first suspect — confirm your bundle actually includes Bootstrap 5 CSS (import 'bootstrap/dist/css/bootstrap.min.css' or an equivalent CDN link), since React-Bootstrap ships no CSS of its own. A leftover Bootstrap 4 utility class anywhere in your own markup is a reliable tell of an incomplete migration.
This reflects the well-established v1→v2 contract. Peer dependency ranges and docs can shift between patch releases, so run the npm view check above against the exact versions you intend to pin before committing the migration.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.