next.js icon indicating copy to clipboard operation
next.js copied to clipboard

how could I use bootstrap.css or other library css in our app

Open ckken opened this issue 10 years ago • 17 comments

ckken avatar Oct 27 '16 05:10 ckken

You can use Head component, and implement it on all your pages.

https://github.com/zeit/next.js#head-side-effects

nkzawa avatar Oct 27 '16 06:10 nkzawa

fixed it

ckken avatar Oct 27 '16 10:10 ckken

@nkzawa link is no longer working. @ckken how did you fix this?

bestwestern avatar Apr 19 '17 19:04 bestwestern

@bestwestern the new link -> https://github.com/zeit/next.js#populating-head

sergiodxa avatar Apr 19 '17 20:04 sergiodxa

@ckken Could you kindly tell me how you fixed it?

tharakabimal avatar Apr 28 '17 11:04 tharakabimal

@tharakabimal here's how I implemented Bootstrap v4 into my project's layout file: https://gist.github.com/gustavlrsn/509694de7f4ee5a5d720d218b21f288e

This is through the reactstrap package (which is bootstrap v4, and CSS file not included), and adding the link to the CSS file from the bootstrap CDN in the <Head> component.

gustavlrsn avatar May 01 '17 18:05 gustavlrsn

@ckken Thanks. One quick question. Will this have any effect on code splitting?

tharakabimal avatar May 02 '17 04:05 tharakabimal

@tharakabimal not very well read on how code splitting works in Next.js. However, it will ship the entire CSS file wherever you include that Head component, which might not be ideal as per @rauchg's comment here: https://github.com/zeit/next.js/issues/119#issuecomment-261150085

gustavlrsn avatar May 02 '17 09:05 gustavlrsn

Thanks @gustavlrsn for your answer. I'm testing your setup and getting the following error:

Cannot find module 'react-transition-group/TransitionGroup'

Error: Cannot find module 'react-transition-group/TransitionGroup'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> ([...]/node_modules/reactstrap/lib/Modal.js:27:24)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

My package.json's dependencies are:

  "dependencies": {
    "next": "^2.4.0",
    "react": "^15.5.4",
    "react-addons-css-transition-group": "^15.5.2",
    "react-addons-transition-group": "^15.5.2",
    "react-dom": "^15.5.4",
    "reactstrap": "^4.6.2"
  }

What version of reactstrap are you using?

yemel avatar May 21 '17 20:05 yemel

Fiexed, just needed to install react-transition-group@^1.1.2

yemel avatar May 21 '17 21:05 yemel

This approach of using the link element to a css file from the Head component gives a FOUC, any ideas how to prevent it?

hugotox avatar Aug 29 '17 02:08 hugotox

@ckken How did you manage to implement the nav bar? I'm having trouble adding Link inside NavLink

 return (
            <div>
                <Navbar color="faded" light expand="md">
                    <NavbarBrand href="/">My Blog</NavbarBrand>
                    <NavbarToggler onClick={this.toggle} />
                    <Collapse isOpen={this.state.isOpen} navbar>
                        <Nav className="ml-auto" navbar>
                        <NavItem>
                            <Link href='/about'>
                                <NavLink>About</NavLink>
                            </Link>
                        </NavItem>
                        </Nav>
                    </Collapse>
                </Navbar>
            </div>
        )

tharakabimal avatar Oct 05 '17 11:10 tharakabimal

Did you got any solution to Navbar implementation?

dacharjaya avatar Nov 05 '17 06:11 dacharjaya

@dacharjaya I decided to write my own CSS (styld jsx) . Not using Bootstrap anymore.

tharakabimal avatar Nov 06 '17 04:11 tharakabimal

I got a solution. You should try this.

import Link from "next/link";
import Navbar from 'react-bootstrap/lib/Navbar';
import Nav from 'react-bootstrap/lib/Nav';
import NavItem from 'react-bootstrap/lib/NavItem';
import NavbarBrand from 'react-bootstrap/lib/NavbarBrand';

dacharjaya avatar Nov 06 '17 06:11 dacharjaya

@dacharjaya what difference does this make?

tharakabimal avatar Nov 06 '17 08:11 tharakabimal

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

lock[bot] avatar May 10 '18 17:05 lock[bot]