Saturday, November 16, 2024
Google search engine
HomeLanguagesReact Suite Button Props

React Suite Button Props

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.

The ButtonGroup component is used to group the buttons together in a group.

React Suite ButtonGroups Props:

  • size: This property of the ButtonGroup component is used to change the size of all buttons in the group. It accepts four values: xs, sm, md and lg.
  • vertical: This attribute is used to specify whether we want to create a vertical layout of buttons or horizontal
  • justified: This attribute creates a button with equal width
  • block: Displays ButtonGroup as a block
  • classPrefix: The prefix of the component CSS class

Syntax:

<ButtonGroup>
    <Button>Some Text</Button>
</ButtonGroup>

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 use props vertical to create vertical buttons.

Javascript




import React from "react";
import Button from 'rsuite/Button';
import "rsuite/dist/rsuite.min.css";
import ButtonGroup from 'rsuite/ButtonGroup';
  
function App() {
    return (
        <div style={{ padding: 10 }}>
            <h1 style={{ color: 'green' }}>
                neveropen
            </h1>
            <h3>
                React Suite ButtonGroup Props
            </h3>
            <ButtonGroup vertical >
                <Button color="orange" appearance="primary"  >
                    Button 1
                </Button>
                <Button appearance="primary" color="cyan">
                    Button 2
                </Button>
                <Button appearance="primary" color="violet">
                    Button 3
                </Button>
                <Button color="green" appearance="primary">
                    Button 4
                </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 will use props justified to create equal width buttons. We have also used IconButtons. We have taken icons from https://rsuitejs.com/resources/icons/

Javascript




import React from "react";
import ButtonGroup from 'rsuite/ButtonGroup';
import FileUploadIcon from '@rsuite/icons/FileUpload';
import OffRoundIcon from '@rsuite/icons/OffRound';
import SendIcon from '@rsuite/icons/Send';
import "rsuite/dist/rsuite.min.css";
import TrashIcon from '@rsuite/icons/Trash';
import IconButton from 'rsuite/IconButton';
  
function App() {
    return (
        <div style={{ padding: 10 }}>
            <h1 style={{ color: 'green' }}>
                neveropen
            </h1>
              
            <h3>
                React Suite ButtonGroup Props
            </h3>
              
            <ButtonGroup justified>
                <IconButton icon={<SendIcon />} 
                    color="red" appearance="primary">
                    Red
                </IconButton>
                <IconButton icon={<OffRoundIcon />} 
                    appearance="primary" color="cyan">
                    Cyan
                </IconButton>
                <IconButton icon={<TrashIcon />} 
                    appearance="primary" color="blue">
                    Blue
                </IconButton>
                <IconButton icon={<FileUploadIcon />} 
                    color="yellow" appearance="primary">
                    Yellow
                </IconButton>
            </ButtonGroup>
        </div>
    );
}
  
export default App;


Output:

 

Reference: https://rsuitejs.com/components/button/#code-lt-button-group-gt-code

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments