Open In App

React Suite Vertical button group

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 Button component is used to fire an action when the user clicks the button. In this article, we will be learning about the React Suite Vertical button group. The ButtonGroup component along with the vertical property is used to group a set of buttons vertically.

React Suite Vertical Button Group Components:



React Suite Vertical Button Groups Props:

Syntax:



<ButtonGroup vertical>
     <Button>...</Button>
     <Button>...</Button>
     <Button>...</Button>
</ButtonGroup>

Creating React Application And Installing Module:

npx create-react-app foldername
cd foldername
npm install rsuite

Project Structure: After completing the above steps, the project structure will look like the following:

Project Structure

Example 1: Now write down the following code in the App.js file. Here, App is our default component. In this example, we made two vertical button groups using the ButtonGroup component along with the vertical property provided by the rsuite library.




import React from "react";
import { ButtonGroup, Button } from "rsuite";
 
// Default CSS
import "rsuite/dist/rsuite.min.css";
 
function App() {
  return (
    <div className="App" style={{ textAlign: "center" }}>
      <header style={
          { display: "block", marginBottom: "20px" }
      }>
        <h3 style={{ color: "green" }}>GeeksforGeeks</h3>
        <h5>React Suite Vertical Button Group</h5>
      </header>
 
      {/* Vertical - Button Group 1 */}
      <ButtonGroup vertical>
        <Button>Button 1</Button>
        <Button>Button 2</Button>
        <Button>Button 3</Button>
      </ButtonGroup>
 
      {/* Vertical - Button Group 2 */}
      <ButtonGroup style={{ margin: "20px" }} vertical>
        <Button appearance="primary">
            Button 1
        </Button>
        <Button appearance="primary">
            Button 2
        </Button>
        <Button appearance="primary">
            Button 3
        </Button>
        <Button appearance="primary">
            Button 4
        </Button>
        <Button appearance="primary">
            Button 5
        </Button>
      </ButtonGroup>
    </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 used the size property of the ButtonGroup Component to control the size of the vertical button groups.




import React from "react";
import { ButtonGroup, Button } from "rsuite";
 
// Default CSS
import "rsuite/dist/rsuite.min.css";
 
function App() {
    return (
 
        <div className="App" style={{ textAlign: "center" }}>
            <header style={
                { display: "block", marginBottom: "20px" }
            }>
                <h3 style={{ color: "green" }}>
                    GeeksforGeeks
                </h3>
                <h5>React Suite Vertical Button Group</h5>
            </header>
 
            {/*Small Vertical Button Group 2 */}
            <ButtonGroup style={{ margin: "20px" }}
                vertical size="sm">
                <Button appearance="primary">
                    Button 1
                </Button>
                <Button appearance="primary">
                    Button 2
                </Button>
                <Button appearance="primary">
                    Button 3
                </Button>
                <Button appearance="primary">
                    Button 4
                </Button>
                <Button appearance="primary">
                    Button 5
                </Button>
            </ButtonGroup>
 
            {/*Medium Vertical Button Group 2 */}
            <ButtonGroup style={{ margin: "20px" }}
                vertical size="md">
                <Button appearance="primary">
                    Button 1
                </Button>
                <Button appearance="primary">
                    Button 2
                </Button>
                <Button appearance="primary">
                    Button 3
                </Button>
                <Button appearance="primary">
                    Button 4
                </Button>
                <Button appearance="primary">
                    Button 5
                </Button>
            </ButtonGroup>
 
            {/*Large Vertical Button Group 2 */}
            <ButtonGroup style={{ margin: "20px" }}
                vertical size="lg">
                <Button appearance="primary">
                    Button 1
                </Button>
                <Button appearance="primary">
                    Button 2
                </Button>
                <Button appearance="primary">
                    Button 3
                </Button>
                <Button appearance="primary">
                    Button 4
                </Button>
                <Button appearance="primary">
                    Button 5
                </Button>
            </ButtonGroup>
        </div>
    );
}
 
export default App;

Output:

 

Reference: https://rsuitejs.com/components/button/#vertical-group


Article Tags :