Is it possible to use Bootstrap in React Js app? - reactjs

Can I use Bootstrap in my React Js App? if yes, then how do i use? I would be great if you can help me out with some example.

Yes, you can install bootstrap by npm i bootstrap and import the css in App.js file like this import 'bootstrap/dist/css/bootstrap.cssbut you can also use react-bootstrap for the pre-created bootstrap component:
npm i react-bootstrap

Yes you can use bootstrap in react
npm install react-bootstrap bootstrap
or yarn add react-bootstrap bootstrap
import this in app.js
import 'bootstrap/dist/css/bootstrap.min.css';

Related

how to import whole Material UI library in React JS

I am creating React web page using Material UI. For using any element I need to import that element.
So I want know how to import whole Material UI library.
As we import required components in particular component so same we have to follow when we import material-ui. Hence in individual component we have to add import statement with particular components as::
import { Button } from '#material-ui/core';
or if multiple components then we can use comma separated import as
import { Button, Text } from '#material-ui/core';
Try this
import { Button, TextField } from '#material-ui/core';
in this article, https://material-ui.com/guides/minimizing-bundle-size/
To import material ui library as a whole with every single feature, you need to install multiple dependencies and import all of them.
First Import
// with npm
npm install #material-ui/core
// with yarn
yarn add #material-ui/core
The font cdn link used by material UI is
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
The icons of the material UI cdn link is
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
The svg icons in material UI
// with npm
npm install #material-ui/icons
// with yarn
yarn add #material-ui/icons

React-bootstrap carousel styles don't applying

I have installed react-bootstrap with:
npm install react-bootstrap bootstrap
command, and successfully imported it:
import Carousel from 'react-bootstrap/Carousel'
<Carousel>
...
</Carousel>
but it's styles didn't applied!
What I need to do to use it correctly?
React-Bootstrap doesn't come with bootstrap CSS automatically - it only produces the corresponding div elements with classes.
If you're using css modules, import the bootstrap css in index.js:
import "bootstrap/dist/css/bootstrap.min.css";
If you're using normal HTML, include bootstrap.min.css in your html file somehow.

How to add Bootstrap to React app and use classes inside

Can someone please explain how to add bootstrap to react app and how to use them inside react components since we can not add CDN links and "class" attribute inside a react app. Would you kindly please explain how to use bootstrap components inside react app. This will really helpful for me since i'm a very beginner to react developer..
Read this
https://react-bootstrap.github.io/getting-started/introduction
1. install react-bootstrap
npm install react-bootstrap bootstrap
2. import css file in your index.js or app.js
import 'bootstrap/dist/css/bootstrap.min.css';
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
3. import components like
import { Button } from 'react-bootstrap';
You can use normal bootstrap classes like className="row"
You can't use bootstrap directly in react application instead you can use reactstrap which contains the bootstrap components.
Example of using reactstrap inside react
import React from 'react';
import { Button } from 'reactstrap';
export default (props) => {
return (
<Button color="danger">Danger!</Button>
);
};
If you want standard Bootstrap
install
npm i bootstrap
import in App.js
import 'bootstrap/dist/css/bootstrap.css';
import "bootstrap"; // <-- JS File

Include bootstrap in react component in codepen

How do I add bootstrap classes to my jsx in codepen? I was trying to add container-fluid, row, and col-* to my divs in jsx but they're not working, anyone knows how?
Install bootstrap :
npm install bootstrap
Then add the following import statement to index.js file
import 'bootstrap/dist/css/bootstrap.css';
instead of writing <div class="container-fluid"></div> you write
<div className="container-fluid"></div>

fontawesome icon not working correctly in react.js

Can anyone give me an example of using font-awesome in React.js?
I have imported the react font-awesome. But the icon doesn't show on the browser. I can see the classname has been set on the dom but there is no CSS style associated with the dom.
Steps followed by me
1) npm install --save react-fontawesome
2) Inside my JS file :
import FontAwesome from 'react-fontawesome';
<FontAwesome name="rocket size="lg"" />
If you are using webpack with react.js what you need to do is to load the font with a loader, first install font-awesome and then
configure the loader in webpack.
{
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
}
try it out and let me know.
Edit:
I forgot to mention that you should import font awesome CSS
import 'font-awesome/css/font-awesome.css'
then just reference like any other class like:
<span className="fa fa-facebook"></span>
Late to the party, but the easiest way is to use #fortawesome/react-fontawesome as mentioned on fontawesome website.
install the package with
yarn add #fortawesome/fontawesome-svg-core
yarn add #fortawesome/free-solid-svg-icons
yarn add #fortawesome/react-fontawesome
After that simply import the pack
import { faCog } from "#fortawesome/free-solid-svg-icons"
And use it
<FontAwesomeIcon icon={faCog} />

Resources