Open In App

React Suite Dropdown Extends button props

A React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application.

In this article, we’ll learn about React suite dropdown extended button props. As we know that the default value for toggling a Dropdown is Button but if we want to set the button sizes or appearance later then we can use extended props of button-like size, and appearance and then display it in button styles.



Syntax:

//Import Statement
import { Dropdown, ButtonToolbar } from "rsuite/";

//App.Js File
const CustomDropDown = (props) => (
    <Dropdown {...props} placement="bottomEnd">
        <Dropdown.Item>...</Dropdown.Item>
    </Dropdown>
);

Function App() {
    return (
        <ButtonToolbar>
            <CustomDropDown title="..." size="lg" />
        </ButtonToolbar>
    );
}

Dropdown Props:



Dropdown.Item Props:

Dropdown.Menu Props:

Creating React Application And Installing Module:

Step 1: Create a React application using the given command:

npm create-react-app projectname

Step 2: After creating your project, move to it using the given command:

cd projectname

Step 3: Now Install the rsuite node package using the given command:

npm install rsuite

Project Structure: Now your project structure should look like the following:

 

Example 1: Below example demonstrates the size extended prop of the dropdown button.




import React from "react";
import "rsuite/dist/rsuite.min.css";
import { Dropdown, ButtonToolbar } from "rsuite/";
  
const CustomDropDown = (props) => (
    <Dropdown {...props} placement="bottomEnd">
        <Dropdown.Item>Java</Dropdown.Item>
        <Dropdown.Item>C++</Dropdown.Item>
        <Dropdown.Item>Python</Dropdown.Item>
    </Dropdown>
);
  
export default function App() {
    return (
        <center>
            <div style={{ padding: 20 }}>
                <h2>GeeksforGeeks</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Dropdown Extends Button props
                </h4>
  
                <div style={{ marginTop: 20 }}>
                    <ButtonToolbar>
                        <CustomDropDown title="Find Courses" 
                                         size="lg" />
                    </ButtonToolbar>
                </div>
            </div>
        </center>
    );
}

Output:

 

Example 2: Below example demonstrates the appearance and size of extended props of the dropdown button.




import React from "react";
import "rsuite/dist/rsuite.min.css";
import { Dropdown, ButtonToolbar } from "rsuite/";
  
const CustomDropDown = (props) => (
    <Dropdown {...props} placement="bottomEnd">
        <Dropdown.Item>Java</Dropdown.Item>
        <Dropdown.Item>C++</Dropdown.Item>
        <Dropdown.Item>Python</Dropdown.Item>
    </Dropdown>
);
  
export default function App() {
    return (
        <center>
            <div style={{ padding: 20 }}>
                <h2>GeeksforGeeks</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Dropdown Extends Button props
                </h4>
  
                <div style={{ marginTop: 20 }}>
                    <ButtonToolbar>
                        <CustomDropDown title="Buy online" 
                            size="sm" appearance="primary" />
                    </ButtonToolbar>
                </div>
            </div>
        </center>
    );
}

Output:

 

Reference: https://rsuitejs.com/components/dropdown/#extends-button-props


Article Tags :