Skip to content
Related Articles

Related Articles

Improve Article

ReactJS Reactstrap Breadcrumb Component

  • Last Updated : 28 Jul, 2021

Reactstrap is a popular front-end library that is easy to use React Bootstrap 4 components. This library contains the stateless React components for Bootstrap 4. Breadcrumb Component provides a way to indicate the location of the current page. We can use the following approach in ReactJS to use the ReactJS Reactstrap Breadcrumb Component.

Breadcrumb Props:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • tag: It is used to denote the tag for this component.
  • listTag: It is used to denote the list tag like ol, ul, etc.
  • className: It is used to denote the class name for the Breadcrumb component.
  • listClassname: It is used to denote the class name for list styling.
  • cssModule: It is used to denote the CSS module for styling.
  • children: It is used to pass the children element to this component.
  • aria-label: It is used to denote the aria-label attribute.

BreadcrumbItem Props:

  • tag: It is used to denote the tag for this component.
  • active: It is used to indicate whether the Item is in active state or not.
  • className: It is used to denote the class name for styling.
  • cssModule: It is used to denote the CSS module for styling.



 

Creating React Application And Installing Module:

Step 1: Create a React application using the following command:

npx create-react-app foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command:

cd foldername

Step 3: After creating the ReactJS application, Install the required module using the following command:

npm install reactstrap bootstrap

Project Structure: It will look like the following.

Project Structure

Example 1: Now write down the following code in the App.js file. Here, we have used the Breadcrumb component with active and href props.

Javascript






import React from 'react'
import 'bootstrap/dist/css/bootstrap.min.css';
import { Breadcrumb, BreadcrumbItem } from "reactstrap"
  
function App() {
    return (
        <div style={{
            display: 'block', width: 700, padding: 30
        }}>
            <h4>ReactJS Reactstrap Breadcrumb Component</h4>
            <Breadcrumb>
                <BreadcrumbItem><a href="#">Dashboard</a></BreadcrumbItem>
                <BreadcrumbItem active>Profile</BreadcrumbItem>
            </Breadcrumb>
            <Breadcrumb>
                <BreadcrumbItem><a href="#">Logout</a></BreadcrumbItem>
                <BreadcrumbItem><a href="#">Settings</a></BreadcrumbItem>
            </Breadcrumb>
        </div>
    );
}
  
export default App;

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

 

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

 

Example 2: Now write down the following code in the App.js file. Here, we have used the Breadcrumb component with disabled, tag, and href props.

App.js 

Javascript




import React from 'react'
import 'bootstrap/dist/css/bootstrap.min.css';
import { Breadcrumb, BreadcrumbItem } from "reactstrap"
  
function App() {
    return (
        <div style={{
            display: 'block', width: 700, padding: 30
        }}>
            <h4>ReactJS Reactstrap Breadcrumb Component</h4>
            <Breadcrumb listTag="div" tag="nav" >
                <BreadcrumbItem disabled>Dashboard</BreadcrumbItem>
                <BreadcrumbItem href="#" tag="a" >Profile</BreadcrumbItem>
                <BreadcrumbItem href="#" tag="a" >Logout</BreadcrumbItem>
                <BreadcrumbItem disabled>Settings</BreadcrumbItem>
            </Breadcrumb>
        </div>
    );
}
  
export default App;

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Output

Reference: https://reactstrap.github.io/components/breadcrumbs/




My Personal Notes arrow_drop_up
Recommended Articles
Page :