To use Bootstrap and CSS together, include the Bootstrap stylesheet via a CDN link or import it into your project. Combine this with custom CSS files for your unique styles. Make sure your custom CSS is loaded after Bootstrap’s styles so it can override the default styles effectively. You can also use preprocessors like Sass for greater customization and flexibility.
React Bootstrap tutorial
Key takeaways
React Bootstrap integrates Bootstrap’s styling with React, allowing developers to use prebuilt, responsive components without direct DOM manipulation.
Unlike traditional Bootstrap, React Bootstrap provides React-based implementations of Bootstrap components, removing the dependency on jQuery and Popper.js.
By leveraging Bootstrap’s stylesheet, React Bootstrap ensures built-in support for responsive layouts and accessibility.
React Bootstrap allows selective component imports, which leads to cleaner, more efficient code than including the entire Bootstrap library.
Developers can use Sass for custom styling while utilizing features like modals, accordions, and grids to rapidly build prototypes.
Building modern web apps requires balancing speed, responsiveness, and maintainability.
Bootstrap helps with UI consistency, but traditional Bootstrap doesn’t play well with React’s virtual DOM.
Enter React-Bootstrap, a library that lets you use Bootstrap components as native React components without jQuery.
In this blog, we’ll explore how to integrate React Bootstrap and build a fully responsive webpage step-by-step.
Let’s dive in!
Learn React
React is one of the most widely used libraries for building fast, interactive user interfaces. Whether you’re creating small components or full-scale applications, React 19 provides tools that help you build reliable, maintainable, and modern frontend experiences. In this course, you’ll start with the fundamentals: how components work, how state drives changes in the UI, and how interactions shape the user experience. Next, you’ll explore more advanced concepts such as managing growing state needs, structuring clean and predictable forms, working with server data, and applying modern React 19 features that keep your interface responsive as your application becomes more complex. By the end of the course, you’ll be able to build thoughtful, data-driven interfaces with confidence. You’ll have the skills to design components, manage asynchronous data, and structure real-world application logic with the help of a guided Capstone project.
What is React Bootstrap?#
Bootstrap is the most widely used CSS framework for building responsive layouts. Traditionally, Bootstrap relied on jQuery and direct DOM manipulation, which isn’t ideal for React’s virtual DOM. React Bootstrap solves this by providing Bootstrap components as React components, allowing seamless integration with React applications—without requiring jQuery or Popper.js.
Bootstrap 4 depends on jQuery, but jQuery is not ideal for React, as it uses direct DOM manipulation while React uses a virtual DOM. React Bootstrap essentially replaces the Bootstrap JavaScript, so each component has been rebuilt to integrate beautifully with React. This gets rid of the need for jQuery.
Some of the components that React Bootstrap offers are:
- Alerts
- Navbar
- Dropdowns
- Buttons
- Tables
- Pagination
- Overlays
Why use React Bootstrap?#
React Bootstrap is optimized for React, eliminating unnecessary dependencies like jQuery. By leveraging React components instead of direct DOM manipulation, it provides a seamless, ‘native’ React experience with Bootstrap’s styling power. Let’s look at some of the main reasons why you should use React Bootstrap for your apps.
Properties of React Bootstrap#
Let’s have a look at the properties of React Bootstrap:
Insertion to virtual DOM#
React Bootstrap was introduced to allow Bootstrap components to be inserted to the Virtual DOM. These components are actual React components, so there is no need to use jQuery or Popper.js to manipulate the DOM.
Bootstrap stylesheet allows for consistency#
React Bootstrap still relies on the Bootstrap stylesheet, which ensures consistent styling. This means all built-in Bootstrap themes, colors, and utilities continue to work seamlessly with React Bootstrap components.
Accessibility out of box#
Accessibility is super important when it comes to creating your webpage. Crafting accessible components is even easier with React Bootstrap over vanilla Bootstrap.
Cleaner code#
React Bootstrap uses React style components that include all the lengthy class information that Bootstrap would traditionally use. All of this is done under the hood and results in cleaner, more readable code.
Real-world use cases of React Bootstrap#
React Bootstrap is more than just a styling framework—it’s a powerful tool that accelerates development while ensuring consistency and accessibility. Here are three practical scenarios where React Bootstrap shines:
1. How can startups use React Bootstrap for rapid prototyping?#
Scenario: Imagine you’re a front-end developer at a startup, and your team has just landed a pitch meeting with investors. You need a functional dashboard prototype ready within a week to showcase your product’s potential.
Solution: Instead of spending hours styling from scratch, you leverage React Bootstrap’s prebuilt components like Navbar, Cards, and Buttons to quickly structure a professional UI. The grid system helps you organize content efficiently, ensuring a fully responsive layout. By reusing components, you can iterate faster, focus on functionality, and impress stakeholders with a polished prototype.
2. Why do enterprises choose React Bootstrap for scalable dashboards?#
Scenario: You’re part of a large enterprise development team working on an internal dashboard for managing employee performance and analytics. The design needs to be consistent across multiple teams, meet accessibility standards, and be easy to maintain.
Solution: React Bootstrap provides a unified design language with built-in theming and responsive utilities, ensuring a consistent look and feel across the application. The accessible components (such as forms with proper ARIA attributes) reduce the need for manual accessibility fixes. Plus, React Bootstrap’s flexibility allows you to extend styles while keeping maintenance simple, making it the perfect fit for scalable enterprise applications.
3. How does React Bootstrap improve UX for e-commerce websites?#
Scenario: You’re a front-end developer working for an e-commerce company, and your team is tasked with revamping the product listing and checkout pages. The challenge? You need a mobile-first, highly responsive design that works seamlessly across devices while ensuring a smooth shopping experience.
Solution: With React Bootstrap’s flexible grid system, you can dynamically adjust product cards for different screen sizes, ensuring a seamless browsing experience on desktops, tablets, and mobile devices. Components like Carousels help showcase featured products, while modals enhance the checkout experience by providing smooth, non-intrusive pop-ups for cart previews. By leveraging React Bootstrap’s form controls, you can build intuitive checkout flows with validation, improving user engagement and conversion rates.
By leveraging React Bootstrap, teams can save development time, ensure UI consistency, and create accessible, responsive designs without reinventing the wheel.
Practice with React Bootstrap#
If you are unfamiliar with creating a React application, please go through our course. It will help you understand React from scratch and get up-to-date knowledge before progressing here:
The primary goal of this course is to give you an excellent introduction to React and its ecosystem, tackle advanced features, and teach you as many best practices as possible. Furthermore, this course digs deeper into the most popular, latest, and straight forward ways to use React.
The following are the steps when working with React Bootstrap:
Set up your environment#
Before diving into React Bootstrap, ensure you have Node.js and npm (or Yarn) installed on your machine. Then, set up a new React project using Create React App:
npx create-react-app react-bootstrap-tutorial
Once your project is ready, navigate to the React project using the following command:
cd react-bootstrap-tutorial
Install React Bootstrap#
Run the following command to install React Bootstrap and Bootstrap itself:
npm install react-bootstrap bootstrap
After installation, import Bootstrap’s CSS file in your src/index.js or src/App.js:
import 'bootstrap/dist/css/bootstrap.min.css';
This import ensures that your components are styled correctly with Bootstrap’s default theme.
Import components#
According to React Bootstrap, you should refrain from importing the entire react-bootstrap library when you are importing a component. When declaring a component, instead of only importing what you actually need:
Single import from React Bootstrap
//this only imports what we needimport Alert from 'react-bootstrap/Alert';//this imports the whole library and uses object destructuring to grab the Button objectimport { Alert } from 'react-bootstrap';
However, if you need multiple components from the react-bootstrap library, object destructuring is preferred to keep your code DRY.
Multiple imports from React Bootstrap
// Preferred: Import multiple components in a single statement for cleaner and more efficient codeimport { Alert, Form, Button, Card } from 'react-bootstrap';// Avoid: Importing each component separately increases redundancy and makes the code less readableimport Alert from 'react-bootstrap/Alert';import Form from 'react-bootstrap/Form';import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';
The first way allows you to keep from repeating yourself by listing the import statements over and over again, and only changing the component name.
React Bootstrap components#
React Bootstrap offers a wide variety of components. Let’s walk through some of the most common ones.
1. Buttons#
The Button component is a great starting point. Here’s how you can use it:
import React from 'react';import { Button } from 'react-bootstrap';function App() {return (<div className="App"><Button variant="primary">Primary Button</Button><Button variant="secondary">Secondary Button</Button></div>);}export default App;
In the above code:
Lines 1–2: We import the React library and the
Buttoncomponent from thereact-bootstraplibrary.Lines 4–11: We define the functional component
App, which returns JSX that renders a<div>with the class name “App”. Inside this<div>, we include two<Button>components with different variants—one withvariant="primary"and the other withvariant="secondary"—to display buttons styled according to Bootstrap’s primary and secondary themes.Line 13: We export the
Appcomponent as the default export so that it can be imported and rendered elsewhere in our application.
Tip: Experiment with different variants like success, warning, danger, etc., to match your design needs.
2. Navigation bar#
A responsive navigation bar can be built easily using the Navbar component:
import React from 'react';import { Navbar, Nav } from 'react-bootstrap';function Navigation() {return (<Navbar bg="dark" variant="dark" expand="lg"><Navbar.Brand href="#home">React Bootstrap</Navbar.Brand><Navbar.Toggle aria-controls="basic-navbar-nav" /><Navbar.Collapse id="basic-navbar-nav"><Nav className="mr-auto"><Nav.Link href="#home">Home</Nav.Link><Nav.Link href="#link">About</Nav.Link><Nav.Link href="#contact">Contact</Nav.Link></Nav></Navbar.Collapse></Navbar>);}export default Navigation;
This code snippet creates a dark-themed, responsive navigation bar that collapses on smaller screens.
Line 2: We import the
NavbarandNavcomponents from thereact-bootstraplibrary.Lines 4–17: We define a functional component named
Navigationthat returns the JSX structure for our navigation bar.Lines 5–6: We start the JSX return block with the
<Navbar>component, setting its background to dark (bg="dark"), its variant to dark (variant="dark"), and enabling responsive behavior withexpand="lg".Line 7: Inside the
<Navbar>, the<Navbar.Brand>component is used to display the brand name ("React Bootstrap") and link it to the#homesection.Line 8: The
<Navbar.Toggle>component adds a button that toggles the visibility of the collapsible content on smaller screens, with thearia-controlsattribute referencing the collapsible element’s ID.Lines 9–15: The
<Navbar.Collapse>component wraps the collapsible navigation content. Inside it, the<Nav>component (with the classmr-autoto align items) contains three<Nav.Link>components, each linking to different sections: Home, About, and Contact.
Line 20: Finally, we export the
Navigationcomponent as the default export so it can be imported and used in other parts of the application.
3. Layout with grid system#
React Bootstrap leverages Bootstrap’s powerful grid system, allowing you to design responsive layouts with ease:
import React from 'react';import { Container, Row, Col } from 'react-bootstrap';function GridExample() {return (<Container><Row><Col sm={8} style={{ backgroundColor: '#f8f9fa' }}>Main Content</Col><Col sm={4} style={{ backgroundColor: '#e9ecef' }}>Sidebar</Col></Row></Container>);}export default GridExample;
In the above code:
Line 2: We import the
Container,Row, andColcomponents from thereact-bootstraplibrary.Lines 4–13: We define the functional component
GridExamplethat returns JSX to build a responsive grid layout.Line 6: The
<Container>component serves as a wrapper that provides proper spacing and centers the content.Line 7: The
<Row>component creates a horizontal row to arrange the grid columns.Line 8: The first
<Col>component occupies 8 grid columns (usingsm={8}) and applies an inline style with a light background color. It is used to display the “Main Content”.Line 9: The second
<Col>component occupies 4 grid columns (sm={4}) and applies a different inline background style, designated for the “Sidebar”.Lines 10–11: These lines close the
<Row>and<Container>components, respectively.
Line 15: We export the
GridExamplecomponent as the default export, making it available for use in other parts of the application.
Using <Container>, <Row>, and <Col>, you can quickly build layouts that adapt to different screen sizes.
Advanced components and customization#
Let’s discuss some components and customization of React Bootstrap.
Forms and modals#
React Bootstrap makes creating forms and modals straightforward. For instance, a simple modal can be created as follows:
import React, { useState } from 'react';import { Modal, Button } from 'react-bootstrap';function ExampleModal() {const [show, setShow] = useState(false);return (<><Button variant="primary" onClick={() => setShow(true)}>Launch Modal</Button><Modal show={show} onHide={() => setShow(false)}><Modal.Header closeButton><Modal.Title>Modal Heading</Modal.Title></Modal.Header><Modal.Body>This is the modal content.</Modal.Body><Modal.Footer><Button variant="secondary" onClick={() => setShow(false)}>Close</Button><Button variant="primary" onClick={() => setShow(false)}>Save Changes</Button></Modal.Footer></Modal></>);}export default ExampleModal;
In the above code:
Lines 1–2: We import the React library along with the
useStatehook, and we also import theModalandButtoncomponents from thereact-bootstraplibrary.Lines 4–29: We define the functional component
ExampleModal, which will encapsulate our modal functionality.Line 5: We declare a state variable
showusing theuseStatehook with an initial value offalse. Theshowstate determines whether the modal is visible, andsetShowis used to update this state.Lines 7–10: We return a React fragment that contains the main UI elements. The first
<Button>component (with a primary variant) is rendered and, when clicked, callssetShow(true)to display the modal.Line 13: We render the
<Modal>component, where theshowprop is set to the value of theshowstate, controlling the modal’s visibility. TheonHideprop is provided a function that callssetShow(false), allowing the modal to be closed when the backdrop is clicked or when the close button is used.Lines 14–16: Inside the
<Modal>, we render a<Modal.Header>with thecloseButtonattribute, which displays a button to close the modal. It also contains a<Modal.Title>that displays the modal’s heading.Line 17: The
<Modal.Body>contains the main content of the modal, in this case, a simple text string.Lines 18–25: The
<Modal.Footer>includes two<Button>components. The first button has a secondary variant and, when clicked, closes the modal by callingsetShow(false). The second button has a primary variant and similarly closes the modal on click. It could also be used for actions like saving changes before closing.
Line 31: We export the
ExampleModalcomponent as the default export, making it available for use in other parts of our application.
Customizing Bootstrap styles#
While React Bootstrap provides great defaults, you might want to customize its appearance. Here are a few strategies:
Custom CSS: Override Bootstrap classes in your own stylesheet.
Sass variables: If you’re comfortable with Sass, modify Bootstrap’s Sass variables before compiling.
Styled components: Integrate with libraries like styled-components to create custom component styles.
Putting it all together: A sample app#
Let’s combine everything we’ve learned into a small sample app that features a navigation bar, a grid layout, and a modal.
The output of the above application is as follows:
React Bootstrap best practices and tips#
Component reusability: Break down your UI into smaller components. This not only makes your codebase manageable but also leverages the reusability that React champions.
Keep it modular: Isolate custom styles to specific components rather than globally overriding Bootstrap’s classes.
Responsive design: Always test your components on different screen sizes. React Bootstrap’s grid system makes this easier, but always verify on real devices when possible.
Stay updated: React Bootstrap is actively maintained. Check out its official documentation for updates and best practices.
Wrapping up and next steps#
You’ve just created your first application using React and React Bootstrap! Well done! React Bootstrap is pretty straightforward once you get the hang of it.
There’s still a lot more to learn about both React and Bootstrap. Some of the more advanced concepts in React that you’ll want to master are:
- Using TypeScript with React
- React design patterns
- React Tracked
- Firebase and React
If you want to learn React, you can take our comprehensive React 18-based “Learn React” course on Educative, where you’ll build dynamic, interactive user interfaces from scratch using the latest features, best practices, and real-world examples.
React is one of the most widely used libraries for building fast, interactive user interfaces. Whether you’re creating small components or full-scale applications, React 19 provides tools that help you build reliable, maintainable, and modern frontend experiences. In this course, you’ll start with the fundamentals: how components work, how state drives changes in the UI, and how interactions shape the user experience. Next, you’ll explore more advanced concepts such as managing growing state needs, structuring clean and predictable forms, working with server data, and applying modern React 19 features that keep your interface responsive as your application becomes more complex. By the end of the course, you’ll be able to build thoughtful, data-driven interfaces with confidence. You’ll have the skills to design components, manage asynchronous data, and structure real-world application logic with the help of a guided Capstone project.
To explore advanced React concepts further, we recommend Educative’s React learning path. This path covers intermediate and advanced topics on React, app development, and deployment. By the end, you’ll be equipped to build interactive, professional-quality applications.
Backed by Facebook and used by tech companies large and small, React has quickly become the most popular front-end framework in the tech world. Its developers are constantly in high demand. If you’re already familiar with JavaScript, adding React to your skillset is a wise career investment. This path will equip you with the skills to build outstanding apps using React. Take the leap, and become a complete front-end developer today.
Happy learning!
Continue reading about React and CSS#
To deepen your knowledge, explore these related blogs:
Frequently Asked Questions
How do I use Bootstrap and CSS together in React?
How do I use Bootstrap and CSS together in React?
Can we use Bootstrap in React?
Can we use Bootstrap in React?
How to check if Bootstrap is installed in React?
How to check if Bootstrap is installed in React?
How to add Bootstrap 5 to React project?
How to add Bootstrap 5 to React project?
Can I use Bootstrap JavaScript plugins directly in React?
Can I use Bootstrap JavaScript plugins directly in React?
How do I resolve conflicts between custom styles and Bootstrap’s default styles in React?
How do I resolve conflicts between custom styles and Bootstrap’s default styles in React?
Why aren’t my Bootstrap styles applying correctly in my React components?
Why aren’t my Bootstrap styles applying correctly in my React components?
How do I integrate Bootstrap into my React project?
How do I integrate Bootstrap into my React project?
How can I customize Bootstrap styles in my React application?
How can I customize Bootstrap styles in my React application?