How to add icon to react-bootstrap navBar?

Kenneth picture Kenneth · Nov 29, 2016 · Viewed 22.7k times · Source

I'm using react-bootstrap and trying to add an icon to the NavBar

      <Navbar.Header>
        <Navbar.Brand>
          <a href="#">&#9776; React-Bootstrap
          <img src={logo} style={{width:100, marginTop: -7}} />
          </a>
        </Navbar.Brand>
        <Navbar.Toggle />
      </Navbar.Header>

However, the icon is not positioned properly in the navbar

enter image description here

And from the official site, i can't find any example of adding icon to the navbar.

Thanks

Answer

wolendranh picture wolendranh · Nov 29, 2016

I think you will need to add a bit of CSS there.

.navbar-brand {
  display: flex;
  align-items: center;
}
.navbar-brand>img {
  padding: 7px 14px;
}

Check working example on JSFiddle

Depending on your image size you can adjust it for your code