Registry / web-framework / react-bootstrap

react-bootstrap

JSON →
library2.10.10jsnpmunverified

React-Bootstrap is a complete re-implementation of the Bootstrap 5 components using React, removing the need for jQuery. It provides a set of accessible and customizable React components that mirror Bootstrap's visual style and functionality. The current stable version is 2.10.10, with active development on a new major version (v3.0.0-beta.x) that introduces further breaking changes and improvements like enhanced ESM support. This library is a popular choice for developers who want to leverage Bootstrap's extensive styling framework within a React application without the performance overhead or potential conflicts of integrating traditional Bootstrap's JavaScript. Releases are frequent for both maintenance and beta branches, ensuring timely bug fixes and new features.

npm install react-bootstrap
INSTALL
IMPORT
SIG · REACT-BOOTSTRAP
R
react-bootstrap
web-frameworkjavascriptv2.10.10
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Button
import Button from 'react-bootstrap/Button';
import { Button } from 'react-bootstrap';
For optimal bundle size, import individual components directly from their sub-paths.
Modal
import Modal from 'react-bootstrap/Modal';
const Modal = require('react-bootstrap').Modal;
ESM imports are the recommended pattern. CommonJS `require` is not officially supported or documented for modern versions.
Navbar
import Navbar from 'react-bootstrap/Navbar';
Sub-component imports like `Navbar.Brand` are accessed via the main Navbar component object, e.g., `Navbar.Brand`.
Form
import Form from 'react-bootstrap/Form';
The `Form` component also exports sub-components like `Form.Control` and `Form.Group`.

Demonstrates a basic React-Bootstrap setup with a button that opens a modal containing a form, showcasing component imports and state management.

import React, { useState } from 'react'; import Button from 'react-bootstrap/Button'; import Modal from 'react-bootstrap/Modal'; import Form from 'react-bootstrap/Form'; import Container from 'react-bootstrap/Container'; function MyFormModal() { const [show, setShow] = useState(false); const handleClose = () => setShow(false); const handleShow = () => setShow(true); const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); console.log('Form submitted!'); handleClose(); }; return ( <Container className="p-4"> <Button variant="primary" onClick={handleShow}> Launch demo modal </Button> <Modal show={show} onHide={handleClose}> <Modal.Header closeButton> <Modal.Title>Login</Modal.Title> </Modal.Header> <Modal.Body> <Form onSubmit={handleSubmit}> <Form.Group className="mb-3" controlId="formBasicEmail"> <Form.Label>Email address</Form.Label> <Form.Control type="email" placeholder="Enter email" /> <Form.Text className="text-muted"> We'll never share your email with anyone else. </Form.Text> </Form.Group> <Form.Group className="mb-3" controlId="formBasicPassword"> <Form.Label>Password</Form.Label> <Form.Control type="password" placeholder="Password" /> </Form.Group> <Button variant="secondary" onClick={handleClose} className="me-2"> Close </Button> <Button variant="primary" type="submit"> Submit </Button> </Form> </Modal.Body> </Modal> </Container> ); } export default MyFormModal;
Debug
Known issues
breakingReact-Bootstrap v3.0.0-beta.1 introduces breaking changes, including migration to the `clsx` library for class name management. Existing custom class logic might need adjustments.
fix
Review your custom class handling and CSS for components. If directly manipulating class names based on `react-bootstrap`'s internal class logic, ensure compatibility with `clsx`'s behavior or adjust to use `className` prop directly.
affects: >=3.0.0-beta.1
breakingThe `Offcanvas` component underwent a significant change in its rendering behavior in v3.0.0-beta.1. This may affect how it integrates into existing layouts or state management.
fix
Consult the `react-bootstrap` v3 migration guide for specific details on `Offcanvas` rendering changes and update your component usage accordingly. Test thoroughly.
affects: >=3.0.0-beta.1
gotchaReact-Bootstrap components require the Bootstrap CSS stylesheet to be included in your project for proper styling. Without it, components will appear unstyled.
fix
Import Bootstrap CSS globally, e.g., `import 'bootstrap/dist/css/bootstrap.min.css';` in your `index.js` or `App.js`, or link it in your HTML.
affects: >=0.1.0
gotchaWhen upgrading React-Bootstrap, especially between minor versions of v2, ensure your React and React-DOM peer dependencies match the specified ranges to avoid type conflicts or runtime errors, particularly with React 19.
fix
Check the `peerDependencies` in `react-bootstrap`'s `package.json` for the version you are installing and ensure your project's `react` and `react-dom` versions satisfy these requirements. Upgrade or downgrade React if necessary.
affects: >=2.10.7
Errors
Common errors & fixes
TypeError: (0 , react_bootstrap_Button__WEBPACK_IMPORTED_MODULE_2__.default) is not a function
Incorrectly using named import for a default export from a sub-path, or attempting to use a CommonJS `require` call with a modern React setup.
fix
Ensure you are using `import Button from 'react-bootstrap/Button';` for default exports from sub-paths, and `import { NamedExport } from 'react-bootstrap';` for named exports directly from the main package if applicable. Avoid CommonJS `require` for components.
Module not found: Error: Can't resolve 'bootstrap/dist/css/bootstrap.min.css'
The Bootstrap CSS file is not found, likely because `bootstrap` is not installed or the import path is incorrect.
fix
Install Bootstrap as a dependency: `npm install bootstrap` or `yarn add bootstrap`, and ensure the import path `import 'bootstrap/dist/css/bootstrap.min.css';` is correct in your main application file.
Upgrade
Version history
2.10.10latest on npm
Audit
Dependencies
reactrequiredCore React library for UI rendering.
react-domrequiredReact's entry point for DOM-specific rendering.
@types/reactoptionalTypeScript type definitions for React. Required when using TypeScript.
Agent activity
4 hits · last 30 days
node
4
Resources
react-bootstrap — npm install react-bootstrap · libregistry