React
Bootstrap
Web Development
Frontend
Navbar
JavaScript
UI Design

How to Add a Navbar Using React Bootstrap

Listen to article
Deepak Tewatia
October 23, 2025
3 min read

Introduction

A navbar is a key part of many websites. It helps users find their way around. In this article, we will show you how to add a simple navbar using React Bootstrap. You'll learn step by step how to set it up and make your site look better and easier to use. Let’s get started!

What is React Bootstrap?

React Bootstrap is a library that lets you use Bootstrap components in a React app. It combines the power of React with the look and feel of Bootstrap. This means you can build beautiful user interfaces without much hassle. The good part? You do not need to worry about jQuery when using React Bootstrap.

Setting Up Your Project

First, you need to set up your React project. If you haven’t created one yet, here’s how to do it:

npx create-react-app my-navbar-app
cd my-navbar-app

Next, you will install React Bootstrap. This is easy to do. Just run the following command:

npm install react-bootstrap bootstrap

Now, you have everything ready to add Bootstrap styles to your project. Don't forget to include the Bootstrap CSS. Open the src/index.js file and add this line at the top:

import 'bootstrap/dist/css/bootstrap.min.css';

Creating the Navbar Component

Let’s make the navbar. Create a new file called Navbar.js inside the src folder. This file will hold our navbar code. Here’s a simple example of what your navbar could look like:

import React from 'react';
import { Navbar, Nav } from 'react-bootstrap';

const MyNavbar = () => {
    return (
        <Navbar bg="light" expand="lg">
            <Navbar.Brand href="#home">My Website</Navbar.Brand>
            <Navbar.Toggle aria-controls="basic-navbar-nav" />
            <Navbar.Collapse id="basic-navbar-nav">
                <Nav className="me-auto">
                    <Nav.Link href="#home">Home</Nav.Link>
                    <Nav.Link href="#about">About</Nav.Link>
                    <Nav.Link href="#contact">Contact</Nav.Link>
                </Nav>
            </Navbar.Collapse>
        </Navbar>
    );
};

export default MyNavbar;

In this code, we import Navbar and Nav from React Bootstrap. We then set up a basic navbar with links for Home, About, and Contact. You can change these links to whatever fits your site.

Using the Navbar Component

Now that you have your navbar, it’s time to use it in your app. Open the src/App.js file and import your new navbar. Add it to your application's layout like this:

import React from 'react';
import MyNavbar from './Navbar';

function App() {
    return (
        <div>
            <MyNavbar />
            <h1>Welcome to My Website</h1>
            <p>This is a simple website using React and Bootstrap.</p>
        </div>
    );
}

export default App;

Here, we simply added <MyNavbar /> at the top of our main app component. This way, the navbar shows up across the top of your site.

Styling the Navbar

The default look of the navbar is nice, but you might want to change it a bit. You can easily do that with custom CSS. Create a new file called Navbar.css and link it in your Navbar.js file:

import './Navbar.css';

Then, you can add your styles in Navbar.css. For example:

.navbar {
    border-bottom: 2px solid #333;
}
.nav-link {
    color: #007bff !important;
}

Final Touches

Now your navbar should look and feel great! You can add more links or dropdowns if needed. React Bootstrap makes it easy to customize your navbar according to your needs. Always remember to test how it looks on different screen sizes. Bootstrap helps with this, as it is responsive by design.

Conclusion

In this guide, you learned how to add a simple navbar to your React app using React Bootstrap. We covered the basics: setting up a new project, creating a navbar component, and styling it. With these steps, you can create a navbar that fits perfectly with your site's design and helps users navigate easily.

Comments

Y
You
Commenting
0/2000
Loading comments…