Skip to content
Related Articles

Related Articles

React Suite Button Disabled

View Discussion
Improve Article
Save Article
  • Last Updated : 13 Jun, 2022
View Discussion
Improve Article
Save Article

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 seeing React Suite Button Disabled

The disabled property of the Button component is used to disable the Button. Disabled buttons are used when we do not want the user to click the button.

React Suite Button Disabled Components:

  • Button: This is the most basic component used to create a button.

React Suite Button Disabled Props:

  • disabled: It is a boolean property used to disable the Button.
  • color: This property of the Button component is used to change the color of the button. The color property can have any one of seven values: red, orange, yellow, green, cyan, blue, or violet.

Syntax:

<Button disabled>Disabled Button</Button>

Creating React Application And Installing Module:

  • Step 1: Create a React application using the following command:
npx create-react-app foldername
  • Step 2: Move to the newly created project folder using the following command:
cd foldername
  • Step 3: After creating the ReactJS application, Install the required module ( rsuite in this case ) using the following command:
npm install rsuite

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

Project Structure

Example 1: In the following example, we used the disabled property of the Button component to disable the button.

Javascript




import React from "react";
import { Button } from "rsuite";
  
// Default CSS
import "rsuite/dist/rsuite.min.css";
  
function App() {
    const ButtonStyle = { margin: "10px 10px" };
    return (
  
        <div className="App" style={
                { textAlign: "center", padding: "0 30px" }
            }>
            <header style={
                    { display: "block", marginBottom: "20px" }
                }>
                <h3 style={{ color: "green" }}>
                    GeeksforGeeks
                </h3>
                <h5>React Suite Button Disabled</h5>
            </header>
  
            <Button disabled appearance="default" 
                    style={ButtonStyle}>
                    Disabled Default Button
            </Button>
            <Button disabled appearance="primary" 
                    style={ButtonStyle}>
                    Disabled Primary Button
            </Button>
            <Button disabled appearance="link" 
                    style={ButtonStyle}>
                    Disabled Link Button
            </Button>
            <Button disabled appearance="ghost" 
                    style={ButtonStyle}>
                    Disabled Ghost Button
            </Button>
            <Button disabled appearance="subtle" 
                    style={ButtonStyle}>
                    Disabled Subtle Button
            </Button>
        </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 color property of the Button component along with the disabled property to change the color of the disabled button. 

Javascript




import React from "react";
import { Button } from "rsuite";
  
// Default CSS
import "rsuite/dist/rsuite.min.css";
  
function App() {
    const ButtonStyle = { margin: "10px 10px" };
    return (
        <div className="App" style={
            { textAlign: "center", padding: "0 30px" }
        }>
            <header style={{ display: "block", marginBottom: "20px" }}>
                <h3 style={{ color: "green" }}>
                    GeeksforGeeks
                </h3>
                <h5>React Suite Button Disabled - Color Variation</h5>
            </header>
  
            <Button disabled appearance="primary"
                    color="red" style={ButtonStyle}>
                        Disabled Red Button
            </Button>
            <Button disabled appearance="primary" 
                    color="yellow" style={ButtonStyle}>
                    Disabled Yellow Button
            </Button>
            <Button disabled appearance="primary" 
                    color="cyan" style={ButtonStyle}>
                    Disabled Cyan Button
            </Button>
            <Button disabled appearance="primary" 
                    color="blue" style={ButtonStyle}>
                    Disabled Blue Button
            </Button>
            <Button disabled appearance="primary" 
                    color="violet" style={ButtonStyle}>
                    Disabled Violet Button
            </Button>
        </div>
    );
}
  
export default App;

Output:

 

Reference: https://rsuitejs.com/components/button/#disabled


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!