question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to include bootstrap?

See original GitHub issue

I am building an app using create-react-app and bootstrap. But I am not able to import bootstrap in my app. I tried including it in index.html like this:

        <script src="lib/js/bootstrap.min.js"></script>
        <link rel="stylesheet" href="lib/css/bootstrap.min.css">

but it does not work. So, how can I import bootstrap in my app? Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

52reactions
isaklafleurcommented, Jun 9, 2017

@taion answer helped me, but maybe anyone are interested in a bit more detailed instruction so here it goes… 😉

I’m using React 15.5.4…

  1. npm install --save bootstrap
  2. add import ‘…/node_modules/bootstrap/dist/css/bootstrap.min.css’; to index.js file so you have Bootstrap working in the whole app.
  3. add <button type="button" className="btn btn-primary">Primary</button> in App.js and you should be able to see a blue bootstrap button.

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
import registerServiceWorker from './registerServiceWorker';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import './index.css';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

App.js

import React, { Component } from 'react';

class App extends Component {
  render() {
    return (
      <div>
        <button type="button" className="btn btn-primary">Primary</button>
      </div>
    );
  }
}

export default App;
21reactions
taioncommented, Jul 26, 2016

For the CSS it should probably be

import 'bootstrap/dist/css/bootstrap.css'

BTW.

Bootstrap ships built CSS in their npm package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction - Bootstrap
Looking to quickly add Bootstrap to your project? Use jsDelivr, provided for free by the folks at jsDelivr. Using a package manager or...
Read more >
Bootstrap Get Started - W3Schools
Bootstrap is a free front-end framework for faster and easier web development; Bootstrap includes HTML and CSS based design templates for typography, forms, ......
Read more >
How to add Bootstrap to HTML (Step by Step Guide)
Method 2: Downloading files locally ... Another way of importing Bootstrap to HTML is to directly download the files locally to your HTML...
Read more >
How to Add Bootstrap in a Project ? - GeeksforGeeks
Under the folder, copy the extracted files downloaded from bootstrap. Under the head tag of the HTML file, the CSS needs to be...
Read more >
How to add Bootstrap to your project - Simple Dev
To add Bootstrap to an existing project, you can add the required link tag to your head element and the script tags right...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found