1

I'm trying to make a navbar using react-bootstrap, but when I render it I get this: enter image description here

I'm not getting any error messages, and I can't find any documentation explaining what I've got, but clearly I'm doing something wrong. Any ideas?

This is the code I'm using:

import React from 'react';
import { Navbar, Nav, NavItem } from 'react-bootstrap/lib/';

const Toolbar = () => {
  return (
    <Navbar staticTop collapseOnSelect>
      <Navbar.Header>
        <Navbar.Brand>
          <a href="test">Brandname Goes Here</a>
        </Navbar.Brand>
        <Navbar.Toggle />
      </Navbar.Header>
      <Navbar.Collapse>
        <Nav>
          <NavItem eventKey={1}>Contact Us</NavItem>
          <NavItem eventKey={2}>About Us</NavItem>
        </Nav>
      </Navbar.Collapse>
    </Navbar>
  )
}

export default Toolbar;
Pavindu
  • 2,684
  • 6
  • 44
  • 77
Karis
  • 13
  • 1
  • 5

2 Answers2

1

go to react-bootsrap getting started tab

and copy the link under the <!-- Latest compiled and minified CSS --> description into your index.html <head> tag, and if you installed react-bootstrap using npm, then you can import the navbar like so: import { Navbar, Nav, NavItem } from 'react-bootstrap';

Elias Ghali
  • 823
  • 1
  • 13
  • 29
1

It is clear that you haven't imported bootstrap.min.css. Import it in your index.html as follows.

<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
crossorigin="anonymous"
/>

I cannot recommend to use something like import 'react-bootstrap/*/*.css' because I am not sure which framework and which loaders(eg: webpack) you are using.

Pavindu
  • 2,684
  • 6
  • 44
  • 77
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254