I am encountering an issue with displaying bootstrap icons in a NavLink component despite importing the necessary files.
In my React project, I have installed Bootstrap using npm i bootstrap
and react-bootstrap-icons using npm i react-bootstrap-icons
.
I imported Bootstrap in my index.js file (
import "bootstrap/dist/css/bootstrap.css"
)
and one of my child components contains the following code:
import { DoorClosed } from "react-bootstrap-icons";
import { NavLink } from "react-router-dom";
export default function Header() {
<NavLink to="/Login">
<span className="logoutIcon-container tooltip" id="logoutBtn">
<DoorClosed size={96} color="white" />
<span className="tooltipText">Logout</span>
</span>
</NavLink>
}
Despite this setup, the icon is not visible. I have considered two solutions, but they do not align with my project requirements:
I can try importing the bootstrap grid system by replacing the import statement in index.js with:
. However, this would limit my ability to use Bootstrap classes.import "bootstrap/dist/css/bootstrap-grid.min.css"
An alternative solution is to move the icon outside of the
<NavLink/>
component. Unfortunately, this does not suit my needs as the icon must remain inside the component.
Is there a better solution to address this issue?