Using Bootstrap 5 with React JS - Desi Programmer
文章推薦指數: 80 %
I am going to use react-bootstrap's current version v2.0.0-beta.6 (Bootstrap 5.1) . Although it is in beta , I will be using it as it uses Bootstrap 5.1. In ...
Desi
Programmer
Contact
Blogs
More
Login
Signup
UsingBootstrap5withReactJS
SwitchTolightMode🌞
Share
Follow@desiprogrammer_
TableOfContents
UsingSimplyCSS
UsingReact-Bootstrap
UsingSimplyCSS
AblogaboutusingthelatestBootstrap5withreactJSinCSSstyle.Iamnotgoingtousereact-bootstrapasitisstillinalpha(onthedayofwritingthis).
SettingUp
Willcreateaproject,addbootstrapandaddsasstocustomizebootstrap.
npxcreate-react-appbootstrap5-react
npmibootstrap
npmisass
Nowinoursrcfolder,wewillcreateamain.scssfileandaddthefollowingoverritetoit.
/*makethecustomizations*/
$primary:#2f24c8;
/*importbootstraptosetchanges*/
@import"../node_modules/bootstrap/scss/bootstrap.scss";
Now,importthisscssontopinyourindex.jsfile.
import'./main.scss';
Iwillsimplyaddthefollowingcodetoshowthatourbootstrapsetupalongwithvariableoveriteisworkingcorrectly.
import'./App.css';
functionApp(){
return(
WrongCredentials.
Welcome
UsingBootstrap5withReactJS.
);
}
exportdefaultApp;
UsingReactBootstrap
Iamgoingtousereact-bootstrap'scurrentversionv2.0.0-beta.6(Bootstrap5.1).
Althoughitisinbeta ,IwillbeusingitasitusesBootstrap5.1.
Inmylastblogpost,ItalkedaboutusingBootstrap5withcss,butitwillcausesomeissueswhenYouuseBootstrap'sJScomponentswithReact,suchasalerts.
It'skindofthesameprocessforsettingup,justneedtoaddanextrareact-bootstrap.
npminstallreact-bootstrap@[email protected]
AddingSaastocustomizeBootstrap.
/*makethecustomizations*/
$primary:#2f24c8;
/*importbootstraptosetchanges*/
@import"../node_modules/bootstrap/scss/bootstrap.scss";
Ihaven'treallydigdeeperorworkedonanyexperimental/[email protected],butthebestpartisalotofcustomizationisavailableusingclassNameandotheraresimplyavailableviadocumentation.
SomecodefromApp.js.
import{useState}from"react";
import{Button,Container,Alert,Form,Row,Col}from"react-bootstrap";
functionApp(){
return(
延伸文章資訊
- 1ndthinh8796/react-bootstrap-v2 - GitHub
Bootstrap components built with React. Contribute to ndthinh8796/react-bootstrap-v2 development b...
- 2react-bootstrap - npm
Bootstrap 5 components built with React. Latest version: 2.2.1, last published: 2 days ago. Start...
- 3React-Bootstrap · React-Bootstrap Documentation
js and react-bootstrap.min.js bundles with all components exported on the window.ReactBootstrap o...
- 4BootCDN - Bootstrap 中文网开源项目免费CDN 加速服务
React-Bootstrap 是基于React 实现的Bootstrap 5 组件库.
- 5react-bootstrap - npm Package Health Analysis | Snyk
Learn more about react-bootstrap: package health score, popularity, security, ... react-bootstrap...