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.

override bootstrap class

See original GitHub issue

hi, i am working on feature/bootstrap3 branch. i want to customise bootstrap class like changing the default shape of button or changing the header color of panel header or changing the primary color of a variable etc. can you suggest some method so that i can customise the bootstrap classes according to my need and these customise classes are loaded instead of the default bootstrap.css

also can you show some example how to use ReactCSSTransitionGroup because i am unable to show the transition when page change.

right now i have to override bootstrap classes in every component

:global(ul.navbar-right) {
    padding-right: 0;
  }
:global(.btn) {
    border-radius: 30px;
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
frenzzycommented, Nov 16, 2016

Step 2 and Step 3 are mutually exclusive:

npm install bootstrap --save
/* tools/copy.js */
copyDir('node_modules/bootstrap/dist/css', 'build/public/css'),
copyDir('node_modules/bootstrap/dist/fonts', 'build/public/fonts'),
/* src/components/Html.js */
  <script src="/css/bootstrap.min.css" /> /* external css file */
  /* application css here */
</head>

OR

npm install bootstrap --save
/* src/components/Layout.css */
:global {
  @import 'bootstrap/css/bootstrap.css'; /* critical path css (inline into html) */
}
/* your css here */
1reaction
frenzzycommented, Nov 3, 2016

If you want to use bootstrap everywhere maybe it is a good idea to require it once inside your root component, for example:

/* Layout.js */
import 'bootstrap/js/bootstrap';
import React from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Layout.css';

function Layout({ children }) {
  return React.Children.only(children);
}

export default withStyles(s)(Layout);
/* Layout.css */
:global {
  @import 'bootstrap/css/bootstrap.css';

  /* override bootstrap style globally */
  ul.navbar-right {
    padding-right: 0;
  }

  .btn {
    border-radius: 30px;
  }
} 
/* Button.js */
import React from 'react';
function Button(props) {
  return <button className="btn" type="button" {...props} />
}
export default Button;
/* HomePage.js */
import React from 'react';
import Layout from './Layout';
import Button from './Button';
function HomePage() {
  return (
    <Layout>
      <Button>Press Me!</Button>
    </Layout>
  );
}
export default HomePage;

Page transitions example here: https://github.com/kriasoft/universal-router/issues/15#issuecomment-222808233

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Edit, Customize, and Override Bootstrap CSS to Suit ...
You can override the default styles of Bootstrap elements using two possible methods. The first way — using CSS overrides— applies to sites ......
Read more >
How can I override Bootstrap CSS styles? - Stack Overflow
Yes, overrides should be put in a separate styles.css (or custom.css ) file so that the bootstrap.css remains unmodified. This makes it easier ......
Read more >
How to override Bootstrap CSS? - Themesberg
There are two main ways you can override Bootstrap CSS: ... We recommend using Sass variables because that will not override the regular...
Read more >
Bootstrap custom CSS overrides - YouTube
We continue building our website implementing custom CSS and learning how to override the Bootstrap CSS.
Read more >
Overriding Bootstrap Classes Using CSS - HackerNoon
5) One of the easiest ways to override Bootstrap classes is to add an 'id' to its direct or indirect parent element, like...
Read more >

github_iconTop Related Medium Post

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