Open In App

React Suite Breadcrumb Used with Link in next/link

Last Updated : 28 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. The  Breadcrumb component is used for Navigation purposes. We can display the current page path and quickly return to the history page.

Breadcrumbs can be used with Links also. This will help to add on all the functionalities/styling of Links to breadcrumbs.

Syntax:

<Breadcrumb separator={'>'} >
    <Breadcrumb.Item >
        <Link href={url}>GeeksforGeeks</Link>
    </Breadcrumb.Item >
</Breadcrumb>

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 rsuite

Project Structure: It will look like the following.

 

Example 1: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.

Javascript




import React from 'react';
import Breadcrumb from 'rsuite/Breadcrumb';
import Link from '@mui/material/Link';
  
function App() {
    return (
        <div>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h3>
                React Suite Breadcrumb Used 
                with Link in next/link
            </h3>
              
            <Breadcrumb separator={'>'} >
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }} >
                    <Link href="https://www.geeksforgeeks.org">
                        GeeksforGeeks
                    </Link>
                </Breadcrumb.Item >
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }} >
                    <Link href="https://write.geeksforgeeks.org/">
                        Computer
                    </Link>
                </Breadcrumb.Item>
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }}  >
                    <Link href="https://www.geeksforgeeks.org/contribute/"
                        Science
                    </Link>
                </Breadcrumb.Item>
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }}  >
                    <Link href="https://www.geeksforgeeks.org"
                        Portal
                    </Link>
                </Breadcrumb.Item>
            </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: In this example, we will use a different separator to show breadcrumb with Link.

Javascript




import React from 'react';
import Breadcrumb from 'rsuite/Breadcrumb';
import Link from '@mui/material/Link';
function App() {
    return (
        <div>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h3>
                React Suite Breadcrumb Used 
                with Link in next/link
            </h3>
            <Breadcrumb separator={':'} >
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }} >
                    <Link href="https://www.geeksforgeeks.org">
                        GeeksforGeeks
                    </Link>
                </Breadcrumb.Item >
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }} >
                    <Link href="https://write.geeksforgeeks.org/">
                        Computer
                    </Link>
                </Breadcrumb.Item>
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }}  >
                    <Link href="https://www.geeksforgeeks.org/contribute/">
                        Science
                    </Link>
                </Breadcrumb.Item>
                <Breadcrumb.Item 
                style={{ marginRight: '6px', marginLeft: '6px' }}  >
                    <Link href="https://www.geeksforgeeks.org">
                        Portal
                    </Link>
                </Breadcrumb.Item>
            </Breadcrumb>
        </div>
    )
}
  
export default App;


Output:

 

Reference: https://rsuitejs.com/components/breadcrumb/#used-with-code-link-code-in-code-next-link-code



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads