How to install and use antd in react js?

Hi Friends πŸ‘‹,

Welcome To aGuideHub!

To install and use antd in React js, you have to use the npm or yarn package manager that is how you can install the antd library into your project.

Today, I am going to show you, how to install and use antd in react js.

Install Antd

Install the following packages to use antd in react js.


npm install antd


yarn install antd

Table of contents

  • Create a new React JS project.
  • Import Antd components.
  • Use Antd components in the project.

Let’s start with the first step.

Step 1: Create a new React JS project.

First you have to install the React project. You should use create-react-app command to create a new React project.

npx create-react-app my-app
cd my-app
npm start

Step 2: Import Antd components.

After installing antd, you have to import your React component. To do this, add the following line to the top of your component file.

import { Button } from 'antd';

Step 3: Use Antd components in the project.

In this blog, see the short example to use button component ant design library.

  <Button type="primary">Primary</Button>

ReactJS use Antd example.

This code below is an example, we will import the button component from the ant library, and use button component as a primary type of ant design library.


import { Button } from 'antd';
const App = () => (
    <Button type="primary">Primary</Button>
export default App;

Check the output of the above code example.

React, Antd

Here, we are provided code sandbox links for the above program to install and use antd in React js. Then you can use whenever you went and do the changes as per your requirements.

Try it Yourself

All the best πŸ‘

Premium Content

You can get all the below premium content directly in your mail when you subscribe us


Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts