Open In App

React Suite Button Component

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. Button Component allows the user to take actions, and make choices, with a single tap. We can use the following approach in ReactJS to use the React Suite Button Component.

Button Props:



IconButton Props:

ButtonGroup Props:



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.

Project Structure

Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.

Filename: App.js




import React from 'react'
import 'rsuite/dist/styles/rsuite-default.css';
import { Button } from 'rsuite'
  
export default function App() {
  return (
    <div style={{
      display: 'block', width: 700, paddingLeft: 30
    }}>
      <h4>React Suite Button Component</h4>
      <Button appearance="primary">Primary Button</Button>  <br></br>
      <Button appearance="link">Link Button</Button> <br></br>
      <Button appearance="default">Default Button</Button> <br></br>
      <Button appearance="ghost">Ghost Button</Button> <br></br>
      <Button appearance="subtle">Subtle Button</Button>
    </div>
  );
}

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 learn how can we make equal width buttons . This can be achieved by making justified buttons.




import React from 'react'
import { Button } from 'rsuite'
import ButtonGroup from 'rsuite/ButtonGroup';
import ButtonToolbar from 'rsuite/ButtonToolbar';
import "rsuite/dist/rsuite.min.css";
export default function App() {
return (
    <div >
  <h1 style={{color:'green'}}>GeeksforGeeks</h1>
    <h3>React Suite Button Component</h3>
  <ButtonGroup  justified>
  <Button appearance="primary">Top</Button>
  <Button appearance="subtle">Middle</Button>
  <Button appearance="ghost">Bottom</Button>
</ButtonGroup>
    </div>
);
}

 

OUTPUT

 

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


Article Tags :