Skip to content
Related Articles

Related Articles

React Suite Nav Option Status

Improve Article
Save Article
  • Last Updated : 18 Jun, 2022
Improve Article
Save Article

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. 

Nav Provides a list of various forms of navigation menus, which can be landscape and portrait layouts. Nav Option Status helps to enable or disable any nav Item. 
Syntax:

<Nav>
    <Nav.Item active>Active Item</Nav.Item>
    <Nav.Item disabled>Disabled Item</Nav.Item>
</Nav> 

 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. In this example, we have setUp Option 2 and Option 4 as disabled and set Option 3 as active. 

Javascript




import React, { useState } from 'react';
import 'rsuite/dist/rsuite.min.css';
import { Nav } from 'rsuite';
export default function App() {
  
    return (
        <div>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h3>React Suite Nav Option Status</h3>
            <Nav >
                <Nav.Item >
                    Option 1
                </Nav.Item>
                <Nav.Item disabled>Option 2</Nav.Item>
                <Nav.Item active>Option 3</Nav.Item>
                <Nav.Item disabled>Option 4</Nav.Item>
                <Nav.Item >Option 5</Nav.Item>
            </Nav>
        </div>
    )
}


 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 have learnt to use icons with disabled Nav items. You can use cons from https://rsuitejs.com/resources/icons/ 

Javascript




import React, { useState } from 'react';
import 'rsuite/dist/rsuite.min.css';
import SendIcon from '@rsuite/icons/Send';
import SearchIcon from '@rsuite/icons/Search';
import TrashIcon from '@rsuite/icons/Trash';
import SettingIcon from '@rsuite/icons/Setting';
import ExploreIcon from '@rsuite/icons/Explore';
import { Nav } from 'rsuite';
  
export default function App() {
  
    return (
        <div>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h3>React Suite Nav Option Status</h3>
            <Nav appearance="tabs" >
                <Nav.Item icon={<ExploreIcon />} >
                    Explore
                </Nav.Item>
                <Nav.Item icon={<SearchIcon />} active>
                    Search
                </Nav.Item>
                <Nav.Item icon={<TrashIcon />}>
                    Delete
                </Nav.Item>
                <Nav.Item icon={<SendIcon />} disabled>
                    Send
                </Nav.Item>
                <Nav.Item icon={<SettingIcon />}>
                    Settings
                </Nav.Item>
            </Nav>
        </div>
    )
}


Output:

 

Reference: https://rsuitejs.com/components/nav/#option-status 


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!