Open In App

React Suite Buttons Props

React Suite is a front-end library designed for the middle platform and back-end products.

Button Component allows the user to interact with the webpage. The Button Component has a number of properties of its own like appearance, size, color, etc. 



The props are:

Syntax:



<Button> </Button>

Prerequisite: Introduction and installation reactJs

Creating React Application and Module installation:

Step 1: Create the react project folder, for that open the terminal, and write the command npm create-react-app folder name, if you have already installed create-react-app globally. If you haven’t then install create-react-app globally by using the command npm -g create-react-app or can install locally by npm i create-react-app.

npm create-react-app project

Step 2: After creating your project folder(i.e. project), move to it by using the following command.

cd project

Step 3: Now install the dependency by using the following command:

npm install rsuite

Project Structure: It will look like this:

 

Example 1: We are importing the Button Component from rsuite, and to apply the default styles of the components we are importing “rsuite/dist/rsuite.min.css”.

For the first three buttons, we are looking into the props like color, appearance, active, disable, of the button component.

Then we are passing different values to the as prop of the button component followed by passing on different values to the classPrefix prop of the component.




import { useState } from "react";
import { Button, Message, Notification } from "rsuite";
import "rsuite/dist/rsuite.min.css";
function App() {
    return (
        <div className="App">
            <h4>React Suite Button Prop</h4>
            <Button color="orange" appearance="primary">
                Primary Button
            </Button>
            <Button color="green" appearance="ghost" active>
                Ghost
            </Button>
            <Button color="green" disabled appearance="link">
                Disabled
            </Button>
            <hr />
            <p
                style={{
                    textAlign: "center",
                    color: "red",
                    marginBottom: 10,
                    fontWeight: 900,
                }}
            >
                as Prop
            </p>
  
            <Button as="em">Button as "em"</Button>
            <hr />
            <p
                style={{
                    textAlign: "center",
                    color: "red",
                    marginBottom: 10,
                    fontWeight: 900,
                }}
            >
                classPrefix Prop
            </p>
  
            <Button classPrefix="nav">
                Button classPrefix="nav"</Button>
            <Button classPrefix="modal-title">
                Button classPrefix="modal-title"
            </Button>
            <Button classPrefix="sidenav">
                Button classPrefix="sidenav"</Button>
        </div>
    );
}
  
export default App;

Step to Run Application: Run the application using the following command from the project’s root directory.

npm start

Output:

 

Example 2: To the first button passed the block prop, kept appearance as ‘primary’ and  set color prop as ‘orange’. The second button kept the appearance as ‘primary’ and set the color prop as ‘green’ and added the loading prop.

To the third button kept the appearance of ‘ghost’ and used the size prop to pass a value of ‘lg’ defining large size. To the fourth button kept its appearance as ‘link’, passed a link to the href prop and set color as ‘violet’.




import { useState } from "react";
import { Button, Message, Notification } from "rsuite";
import "rsuite/dist/rsuite.min.css";
function App() {
    return (
        <div className="App">
            <h4>React Suite Button Prop</h4>
            <Button color="orange" appearance="primary" block>
                Block Button
            </Button>
            <Button appearance="primary" color="green" loading>
                Loading ..
            </Button>
            <hr />
            <Button appearance="ghost">Large Button</Button>
            <Button
                color="violet"
                appearance="link"
                href=
            >
                Link
            </Button>
        </div>
    );
}
  
export default App;

Step to Run Application: Run the application using the following command from the project’s root directory.

npm start

Output:

 

 

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


Article Tags :