ReactJS UI Ant Design Button Component
Last Updated :
21 May, 2021
Ant Design Library has this component pre-built, and it is very easy to integrate as well. Button Component provides a way for users to take actions, and make choices, with a single tap. We can use the following approach in ReactJS to use the Ant Design Button Component.
Button Props:
- danger: It is used to set the danger status of the button.
- block: It is used as an option to fit the width of the button to its parent width.
- disabled: It is used to set the button in a disabled state.
- ghost: It is used to invert text and border colors and make the background transparent.
- href: It is used to define the redirect URL of the link button.
- htmlType: It is used to set the original HTML type of button.
- icon: It is used to set the icon component of the button.
- loading: It is used to set the loading status of the button.
- shape: It is used to set a button shape.
- size: It is used to set the size of the button.
- target: It is used as same as the target attribute of <a> tag.
- type: It is used to denote the type of button-like dashed, primary, etc.
- onClick: It is used to trigger a callback function with the click of the button.
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 antd
Project Structure: It will look like the following.
Project StructureExample: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from 'react'
import "antd/dist/antd.css";
import { Button } from 'antd';
export default function App() {
return (
<div style={{ display: 'block', width: 700, padding: 30 }}>
<h4>Ant Design Button Component</h4>
<Button>Default Button</Button> <br />
<Button type="primary">Primary Button</Button> <br />
<Button type="dashed">Dashed Button</Button> <br />
</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:

Reference: https://ant.design/components/button/