Skip to content
Related Articles

Related Articles

React Suite Button Color

View Discussion
Improve Article
Save Article
  • Last Updated : 08 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 discussing the React Suite Button Color. To change the color of the Button the color property is used.

React Suite Button Color Components:

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

React Suite Button Color Props:

  • 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.
  • appearance: This property is used to change the appearance of the button component. It can have any of the five values: default, primary, link, subtle, or ghost.

Syntax:

<Button color="red">Red 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: Now write down the following code in the App.js file. Here, App is our default component. In the following example, we used the Button component’s color property to modify the Button’s color.

Javascript




import React from "react";
import { Button } from "rsuite";
  
// Import the 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 Button Color</h5>
            </header>
  
            {/* Colored Buttons */}
            <Button color="red" appearance="primary">
                Red</Button>
            <Button color="blue" appearance="primary">
                Blue</Button>
            <Button color="orange" appearance="primary">
                Orange</Button>
            <Button color="violet" appearance="primary">
                Violet</Button>
            <Button color="green" appearance="primary">
                Green</Button>
            <Button color="cyan" appearance="primary">
                Cyan</Button>
            <Button color="yellow" appearance="primary">
                Yellow</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: This example shows the use of Button color property with different appearances of buttons.

Javascript




import React from "react";
import { Button } from "rsuite";
  
// Import the 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 Button Color</h5>
            </header>
            {/* Colored Buttons */}
            <Button color="red" appearance="primary">
                Red</Button>
            <Button color="blue" appearance="subtle">
                Blue</Button>
            <Button color="orange" appearance="link">
                Orange</Button>
            <Button color="violet" appearance="ghost">
                Violet</Button>
            <Button color="green" appearance="subtle">
                Green</Button>
            <Button color="cyan" appearance="default">
                Cyan</Button>
            <Button color="yellow" appearance="ghost">
                Yellow</Button>
        </div>
    );
}
  
export default App;

Output:

 

Reference: https://rsuitejs.com/components/button/#colorful-button


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!