How to install bootstrap icons in react js?
April 08, 2023Hi Friends 👋,
Welcome To aGuideHub!
To install bootstrap icons in React js, you have to use the npm
or yarn
package manager that is how you can install the bootstrap icons
library into your project.
Today, I am going to show you, how to install bootstrap icons in react js.
Install Bootstrap icons
Install the following packages to use bootstrap icons
in react js.
npm
npm install bootstrap-icons
Table of contents
- Set up the React project.
- Import necessary components.
- Use Bootstrap icons.
Step 1: Set up the React 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 necessary components.
After installing Bootstrap icons
, you have to import your React component. To do this, add the following line to the top of your component file.
import { ArrowRightCircleFill, ArrowLeftCircleFill } from "react-bootstrap-icons";
import "bootstrap/dist/css/bootstrap.min.css";
Step 3: Use Bootstrap icons.
In this blog, see the short example to ArrowRightCircleFill
and ArrowLeftCircleFill
are displayed via the div
element.
<div>
<ArrowRightCircleFill />
<ArrowLeftCircleFill />
</div>
ReactJS create bootstrap icons example.
The code below is an example of this, we have to style with CSS and include the icons.
App.js
import {
ArrowRightCircleFill,
ArrowLeftCircleFill
} from "react-bootstrap-icons";
import "bootstrap/dist/css/bootstrap.min.css";
export default function MyComponent() {
return (
<div>
<ArrowRightCircleFill />
<ArrowLeftCircleFill />
</div>
);
}
Check the output of the above code example.
Here, we are provided code sandbox links for the above program install bootstrap icons in React js. Then you can use whenever you went and do the changes as per your requirements.
All the best 👍