1. First, we need fresh reactjs setup, and for that, we need to run below commands into out terminal, and also we should have latest node version installed on our system:
npx create-react-app my-awesome-project
cd my-awesome-project
npm start
2. Now we need to run below commands into our project terminal to get bootstrap and related modules into our reactjs application:
npm install [email protected] --save
npm start //For start project again
3. Finally for the main output, we need to add below code into our my-awesome-project/src/App.js file or if you have fresh setup then you can replace my-awesome-project/src/App.js file code with below code:
import React from 'react';
import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css';
function App() {
return (
<div>
<div class="container bootstrap snippets bootdey">
<h1 class="text-center text-success">10 Useful Bootstrap Tricks
<p class="lead">Bootstrap 3.1 and jQuery Snippets</p>
</h1>
<hr/>
<ul class="timeline">
<li>
<div class="timeline-badge info"><i class="glyphicon glyphicon-hand-left"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Shake Button</h2>
<p><small class="text-muted">Click to make it say no</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<button class="btn btn-primary btn-lg" id="shaker">Click Me</button>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge"><i class="glyphicon glyphicon-time"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Progress Bar</h2>
<p><small class="text-muted">A working jQuery example</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<div class="progress progress-striped">
<div class="progress-bar bar" style={{/*width:0%;*/}}></div>
</div>
</div>
</div>
</li>
<li>
<div class="timeline-badge success"><i class="glyphicon glyphicon-hand-up"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Switch Button</h2>
<p><small class="text-muted">Toggle off and on state</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<div class="btn-group btn-toggle">
<button class="btn btn-lg btn-default">ON</button>
<button class="btn btn-lg btn-primary active">OFF</button>
</div>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge info"><i class="glyphicon glyphicon-fast-forward"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Pagination</h2>
<p><small class="text-muted">Paging for sections or paragraphs</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<div id="pages">
<div class="page">
Page 1 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate.
Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero. Aenean sit amet felis
dolor, in sagittis nisi. Sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan.
Aliquam in felis sit amet augue.
</div>
<div class="page">
Page 2 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate.
Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero. Aenean sit amet felis
dolor, in sagittis nisi. Sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan.
Aliquam in felis sit amet augue.
</div>
<div class="page">
Page 3 - More m ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate.
Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero. Aenean sit amet felis
dolor, in sagittis nisi. Sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan.
Aliquam in felis sit amet augue.
</div>
<div class="page">
Page 4 - Final ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate.
Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero. Aenean sit amet felis
dolor, in sagittis nisi. Sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan.
Aliquam in felis sit amet augue.
</div>
</div>
<ul class="pagination" id="myPager"></ul>
</div>
</div>
</li>
<li>
<div class="timeline-badge info"><i class="glyphicon glyphicon-tasks"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Select Button</h2>
<p><small class="text-muted">Turn a Dropdown into a select list</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<div class="btn-group">
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#/">Select an Item <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#/">Item I</a></li>
<li><a href="#/">Item II</a></li>
<li><a href="#/">Item III</a></li>
<li><a href="#/">Item IV</a></li>
<li><a href="#/">Item V</a></li>
<li class="divider"></li>
<li><a href="#/">Other</a></li>
</ul>
</div>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge primary"><i class="glyphicon glyphicon-arrow-right"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Expanding Input (CSS only)</h2>
<p><small class="text-muted">Grows wider when clicked</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<input class="form-control input-md" id="myInput" placeholder="Click here" type="text"/>
</div>
</div>
</li>
<li>
<div class="timeline-badge info"><i class="glyphicon glyphicon-envelope"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Pop-up Email Validation</h2>
<p><small class="text-muted">Live as-you-type validator</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<form id="emailForm">
<div class="form-group"><input class="form-control email" data-placement="top" data-trigger="manual" data-content="Must be a valid e-mail address ([email protected])" placeholder="Enter your email" type="text"/></div>
</form>
</div>
</div>
</li>
<li>
<div class="timeline-badge green"><i class="glyphicon glyphicon-font"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Caps Lock Check</h2>
<p><small class="text-muted">As-you-type for case sensitive passwords</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<form>
<div class="form-group"><input class="form-control" data-placement="top" data-trigger="manual" data-title="Caps lock is on!" placeholder="Password" type="password"/></div>
</form>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge danger"><i class="glyphicon glyphicon-folder-close"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Collapse Tabs</h2>
<p><small class="text-muted">Overflow extra tabs into a Dropdown</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<ul class="nav nav-tabs" id="tabs">
<li><a href="#tab0" data-toggle="tab">Tab0</a></li>
<li><a href="#tab1" data-toggle="tab">Tab1</a></li>
<li><a href="#tab2" data-toggle="tab">Tab2</a></li>
<li><a href="#tab3" data-toggle="tab">Tab3</a></li>
<li><a href="#tab4" data-toggle="tab">Tab4</a></li>
<li><a href="#tab5" data-toggle="tab">Tab5</a></li>
<li><a href="#tab6" data-toggle="tab">Tab6</a></li>
<li><a href="#tab7" data-toggle="tab">Tab7</a></li>
<li><a href="#tab8" data-toggle="tab">Tab8</a></li>
<li id="lastTab">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#/">
More <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="collapsed">
</ul>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="tab0">Tab 0 content...</div>
<div class="tab-pane" id="tab1">Tab 1 content...</div>
<div class="tab-pane" id="tab2">Tab 2 content...</div>
<div class="tab-pane" id="tab3">Tab 3 content...</div>
<div class="tab-pane" id="tab4">Tab 4 content...</div>
<div class="tab-pane" id="tab5">Tab 5 content...</div>
<div class="tab-pane" id="tab6">Tab 6 content...</div>
<div class="tab-pane" id="tab7">Tab 7 content...</div>
<div class="tab-pane" id="tab8">Tab 8 content...</div>
</div>
</div>
</div>
</li>
<li>
<div class="timeline-badge warning"><i class="glyphicon glyphicon-time"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h2 class="timeline-title">Loading Button</h2>
<p><small class="text-muted">Add state to your buttons</small></p>
</div>
<div class="timeline-body">
<h3></h3>
<button type="button" id="loadingBtn" data-loading-text="Loading..." class="btn btn-lg btn-primary">
Click Me
</button>
</div>
</div>
</li>
</ul>
<hr/>
</div>
</div>
);
}
export default App;
4. Now we need to add below code into our my-awesome-project/src/App.css file :
/* expanding input CSS only */
#myInput {width:130px}
#myInput:focus {width:100%;}
body{
background:#eee;
}
.timeline {
list-style: none;
padding: 20px 0 20px;
position: relative;
}
.timeline:before {
top: 0;
bottom: 0;
position: absolute;
content: " ";
width: 3px;
background-color: #eeeeee;
left: 50%;
margin-left: -1.5px;
}
.timeline > li {
margin-bottom: 20px;
position: relative;
}
.timeline > li:before,
.timeline > li:after {
content: " ";
display: table;
}
.timeline > li:after {
clear: both;
}
.timeline > li:before,
.timeline > li:after {
content: " ";
display: table;
}
.timeline > li:after {
clear: both;
}
.timeline > li > .timeline-panel {
width: 46%;
float: left;
border: 1px solid #d4d4d4;
border-radius: 2px;
padding: 20px;
position: relative;
-webkit-box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175);
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175);
}
.timeline > li > .timeline-panel:before {
position: absolute;
top: 26px;
right: -15px;
display: inline-block;
border-top: 15px solid transparent;
border-left: 15px solid #ccc;
border-right: 0 solid #ccc;
border-bottom: 15px solid transparent;
content: " ";
}
.timeline > li > .timeline-panel:after {
position: absolute;
top: 27px;
right: -14px;
display: inline-block;
border-top: 14px solid transparent;
border-left: 14px solid #fff;
border-right: 0 solid #fff;
border-bottom: 14px solid transparent;
content: " ";
}
.timeline > li > .timeline-badge {
color: #fff;
width: 50px;
height: 50px;
line-height: 50px;
font-size: 1.4em;
text-align: center;
position: absolute;
top: 16px;
left: 50%;
margin-left: -25px;
background-color: #999999;
z-index: 100;
border-top-right-radius: 50%;
border-top-left-radius: 50%;
border-bottom-right-radius: 50%;
border-bottom-left-radius: 50%;
}
.timeline > li.timeline-inverted > .timeline-panel {
float: right;
}
.timeline > li.timeline-inverted > .timeline-panel:before {
border-left-width: 0;
border-right-width: 15px;
left: -15px;
right: auto;
}
.timeline > li.timeline-inverted > .timeline-panel:after {
border-left-width: 0;
border-right-width: 14px;
left: -14px;
right: auto;
}
.timeline-badge.primary {
background-color: #2e6da4 !important;
}
.timeline-badge.success {
background-color: #3f903f !important;
}
.timeline-badge.warning {
background-color: #f0ad4e !important;
}
.timeline-badge.danger {
background-color: #d9534f !important;
}
.timeline-badge.info {
background-color: #5bc0de !important;
}
.timeline-title {
margin-top: 0;
color: inherit;
}
.timeline-body > p,
.timeline-body > ul {
margin-bottom: 0;
}
.timeline-body > p + p {
margin-top: 5px;
}
@media (max-width: 767px) {
ul.timeline:before {
left: 40px;
}
ul.timeline > li > .timeline-panel {
width: calc(100% - 90px);
width: -moz-calc(100% - 90px);
width: -webkit-calc(100% - 90px);
}
ul.timeline > li > .timeline-badge {
left: 15px;
margin-left: 0;
top: 16px;
}
ul.timeline > li > .timeline-panel {
float: right;
}
ul.timeline > li > .timeline-panel:before {
border-left-width: 0;
border-right-width: 15px;
left: -15px;
right: auto;
}
ul.timeline > li > .timeline-panel:after {
border-left-width: 0;
border-right-width: 14px;
left: -14px;
right: auto;
}
}