BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications.
Breadcrumbs Component provides a way for users to identify the path to the current resource in an application. We can use the following approach in ReactJS to use the ReactJS Blueprint Breadcrumbs Component.
Breadcrumbs Props:
- breadcrumbRenderer: It is a callback function that is triggered to render visible breadcrumbs.
- className: It is used to denote a space-delimited list of class names to pass along to a child element.
- collapseFrom: It is used to indicate which direction the breadcrumbs should collapse from i.e start or end.
- currentBreadcrumbRenderer: It is a callback function that is triggered to render the current breadcrumb.
- items: It is used to denote all breadcrumbs to display.
- minVisibleItems: It is used to denote the minimum number of visible breadcrumbs that should never collapse into the overflow menu.
- overflowListProps: It is used to denote props to spread to OverflowList.
- popoverProps: It is used to denote props to spread to the Popover showing the overflow menu.
Breadcrumb Props:
- className: It is used to denote a space-delimited list of class names to pass along to a child element.
- current: It is used to indicate whether this breadcrumb is the current breadcrumb.
- disabled: It is used to indicate whether this action is non-interactive.
- href: It is used to denote the Link URL.
- icon: It is used to denote the name of an icon or an icon element to render before the text.
- intent: It is used to denote the visual intent color to apply to the element.
- onClick: It is used to denote a click event handler.
- target: It is used to denote the link target attribute.
- text: It is used to denote the action text.
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. folder name, 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 @blueprintjs/core
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from 'react' import '@blueprintjs/core/lib/css/blueprint.css' ; import { Breadcrumbs } from "@blueprintjs/core" ; function App() { // Sample Breadcrumbs items const sampleItems = [ { href: "/document" , icon: "folder-close" , text: "Document" }, { href: "/document/profile" , icon: "user" , text: "Profile" }, { icon: "document" , text: "Username.jpg" }, ]; return ( <div style={{ display: 'block' , width: 400, padding: 30 }}> <h4>ReactJS Blueprint Breadcrumbs Component</h4> <Breadcrumbs items={sampleItems} /> </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:
Reference: https://blueprintjs.com/docs/#core/components/breadcrumbs