package.json file
{
"name": "myapp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-regular-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0",
"autoprefixer": "^10.4.12",
"postcss": "^8.4.16",
"tailwindcss": "^3.1.8",
"vite": "^3.1.0"
}
}
icontext component here i am trying to add social media icons:
import React from 'react'
const IconsText = () => {
return (
<div className="container-fluid bg-[#1d3943]">
</div>
)
}
export default IconsText
I don't know what i am doing wrong i tried add code but failed what should I do to add icons
In order to add font-awesome icons
you need to make sure you have installed it first. Go to your project folder and execute the command npm install react-icons
or yarn add react-icons
. Now in your component you should import the react-icons
module like:
import * as aiicons from 'react-icons/ai'
react-icons
has each folder corresponding to what you wanna use. Hope this helps!
Check out the font awesome guide on importing icons in react
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.