Wednesday, July 3, 2024
HomeLanguagesReactReactJS Reactstrap Breadcrumb Component

ReactJS Reactstrap Breadcrumb Component

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:

  • 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/

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha Wardslaus
Dominic Rubhabha Wardslaushttps://neveropen.dev
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments