Home > OS >  React and Bootstrap Best Practices (how should I design my website)
React and Bootstrap Best Practices (how should I design my website)

Time:06-16

I am making my first ever website in React. I want to use Bootstrap's grid system, but I don't really know when I should use this or rather how extensively.

Is the grid system best in places like App.js and in each individual component? Just in each individual component? Just in App.js?

CodePudding user response:

We can use plain bootstrap to use grid system. We have to use it inside most of the component according to the requirement to make is responsive.

Easy Option: There are other options to use bootstrap inside react like component libraries. You can use either Reactstrap or React-Bootstrap. These libraries provide components by which you can easily create website with react and power of bootstrap.

CodePudding user response:

I use React-Bootstrap. I've found it very simple to get going with, and the intellisense you get in VS Code is great.

To get started, just:

npm install react-bootstrap

You can see a list of all of the components here.

Then you just add the components that you want to use to your import.

import {
  Navbar,
  Container,
  Nav,
  NavbarBrand,
  Row,
  Col,
  {...}
} from "react-bootstrap";

Then in your rendered output, for example:

return (
      <Container>
        <Navbar>
          <NavbarBrand>Brand</NavbarBrand>
          <Navbar.Collapse>
            <Nav>
              <NavItem>Item 1</NavItem>
            </Nav>
          </Navbar.Collapse>
        </Navbar>
        <Row>
          <Col md={4}>
          </Col>
          <Col md={4}>
          </Col>
          <Col md={4}>
          </Col>
        </Row>
      </Container>
    );

  • Related