Open In App

React Suite Dropdown Menu items

Last Updated : 18 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 dropdown component allows the user to provide navigation that uses a select picker if you want to select a value. 

Dropdown Menu is used to create a menu with some items. It appears as a card containing items. We don’t need to expand it as it is already expanded.

Syntax

<Dropdown.Menu>
    <Dropdown.Item>Item 1</Dropdown.Item>
    <Dropdown.Item>Item 2</Dropdown.Item>
</Dropdown.Menu>

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 will learn to create an easy and simple Dropdown menu 

Javascript




import React from 'react';
import Dropdown from 'rsuite/Dropdown';
import ButtonToolbar from 'rsuite/ButtonToolbar';
import 'rsuite/dist/rsuite.min.css';
  
import Link from '@mui/material/Link';
function App() {
    return (
        <div>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h3>React Suite Menu Items</h3>
  
            <Dropdown.Menu
                style={{
                    width: 200,
                    border: '1px solid #ddd'
                }}>
                <Dropdown.Item >Item A</Dropdown.Item>
                <Dropdown.Item >Item B</Dropdown.Item>
                <Dropdown.Item >Item C</Dropdown.Item>
            </Dropdown.Menu>
            <br></br>
        </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 learn how we can provide some styling to the menu and menu items. In below example, we will provide green color as a background to the Menu and white color to the font of Menu Items.

Javascript




import React from 'react';
import Dropdown from 'rsuite/Dropdown';
import ButtonToolbar from 'rsuite/ButtonToolbar';
import 'rsuite/dist/rsuite.min.css';
  
import Link from '@mui/material/Link';
function App() {
    return (
        <div>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h3>React Suite Menu Items</h3>
  
            <Dropdown.Menu
                style={{
                    width: 200,
                    border: '1px solid #ddd',
                    background: 'green'
                }}>
                <Dropdown.Item style={{ color: 'white' }}>
                    Geeks
                </Dropdown.Item>
                <Dropdown.Item style={{ color: 'white' }}>
                    For
                </Dropdown.Item>
                <Dropdown.Item style={{ color: 'white' }}>
                    Geeks
                </Dropdown.Item>
            </Dropdown.Menu>
        </div>
    )
}
  
export default App;


Output:

 

Reference: https://rsuitejs.com/components/dropdown/#menu-items



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads