List of Components Bootstrap
List of Components Bootstrap
Navigation Bar
A navigation bar is used in every website to make it more user-friendly so
that the navigation through the website becomes easy and the user can
directly search for the topic of their interest. The navigation bar is placed
at the top of the page.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Navigation Bar</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body style="text-align:center;">
<div class="container">
<h1 style="color:green;">
Sample Navbar
</h1>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Navigation Bar</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<div class="container">
<h1 style="color:green;text-align:center;">
Colore Navbar
</h1>
<nav class="navbar navbar-expand-sm bg-primary navbar-dark">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Algo</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">DS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Languages</a>
</li>
</ul>
</nav>
<br><br>
<nav class="navbar navbar-expand-sm bg-success navbar-light">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Algo</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">DS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Languages</a>
</li>
</ul>
</nav>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Navigation Bar</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<div class="container">
<h1 style="color:green;text-align:center;">
DropDown Navbar
</h1>
<h2 style="text-align:center;">Dropdown Navbar</h2>
<nav class="navbar navbar-expand-sm bg-success navbar-dark">
<!-- Brand/logo -->
<a class="navbar-brand" href="#">
<img src=
"https://www.geeksforgeeks.org/wp-content/uploads/
gfg_transparent_white_small.png "
alt="logo"
style="width:40px;">
</a>
<div class="collapse navbar-collapse" id="collapse_Navbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Algo</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">DS</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#"
id="navbardrop" data-toggle="dropdown">
Languages
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
</div>
</li>
</ul>
</div>
</nav>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Navigation Bar</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<div class="container">
<h1 style="color:green;text-align:center;">
Button Navbar
</h1>
<h2 style="text-align:center;">Forms and Buttons Navbar</h2>
<nav class="navbar navbar-expand-sm bg-success navbar-dark">
<div class="collapse navbar-collapse" id="collapse_Navbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Algo</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">DS</a>
</li>
</ul>
</div>
<form class="form-inline" action="#">
<input class="form-control mr-sm-2"
type="text" placeholder="Search">
<button class="btn btn-primary" type="submit">
Search
</button>
</form>
</nav>
</div>
</body>
</html>
Buttons
Bootstrap provides different classes that can be used with different tags,
such as <button>, <a>, <input>, and <label> to apply custom button styles.
Bootstrap also provides classes that can be used for changing the state and
size of buttons. Also, it provides classes for applying toggle, checkbox and
radio buttons like effects.
Bootstrap contains many classes to set the style of the button element. The
list of button classes are given below:
.btn
.btn-primary
.btn-secondary
.btn-success
.btn-info
.btn-warning
.btn-danger
.btn-dark
.btn-light
.btn-link
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Buttons</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/
bootstrap.min.css ">
</head>
<body style="text-align:center;">
<div class="container mt-3">
<h1 style="color:green;">
Button Componant
</h1>
<h2>Buttons</h2>
<button type="button" class="btn btn-primary">
Primary</button>
<button type="button" class="btn btn-secondary">
Secondary</button>
<button type="button" class="btn btn-success">
Success</button>
<button type="button" class="btn btn-warning">
Warning</button>
<button type="button" class="btn btn-danger">
Danger</button>
</div>
</body>
</html>
Note: The <a>, <button> and <input> elements are used to hold the button
classes.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Buttons</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body style="text-align:center;">
<div class="container mt-3">
<h1 style="color:green;">
BUTTON USING INPUT
</h1>
<h2>Button Elements</h2>
<input class="btn btn-success"
type="button" value="Input Button">
<input class="btn btn-success"
type="submit" value="Submit Button">
<input class="btn btn-success"
type="reset" value="Reset Button">
<button class="btn btn-success" type="button">
Button</button>
<a href="#" class="btn btn-success" role="button">
Link Button</a>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Buttons</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body style="text-align:center;">
<div class="container mt-3">
<h1 style="color:green;">
BLOCK BUTTON
</h1>
<h2>Block Level Buttons</h2>
<button type="button"
class="btn btn-block btn-primary">
Block Level Button
</button>
<button type="button"
class="btn btn-block btn-success">
Block Level Button
</button>
</div>
</body>
</html>
Progress Bars
A progress bar is used to display the progress of a process on a computer. A
progress bar displays how much of the process is completed and how much
is left. You can add a progress bar on a web page using predefined bootstrap
classes. Bootstrap provides many types of progress bars.
Syntax:
<div class="progress">
<div class="progress-bar" style="width:x%"></div>
<div>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Progress Bar</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<h1 style="color:green;text-align:center;">
PROGRESS BAR
</h1>
<div class="container">
<div class="progress">
<div class="progress-bar"
style="width:80%">
</div>
</div>
</div>
</body>
</html>
Labeled Progress Bar: The labeled progress bar is used to display the text
inside the progress bar to show the task completion percentage.
Syntax:
<div class="progress">
<div class="progress-bar" style="width:x%">x%</div>
<div>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Progress Bar</title>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body style="text-align:center;">
<h1 style="color:green;">
LABELED PROGRESS BAR
</h1>
<div class="container">
<div class="progress">
<div class="progress-bar"
style="width:80%;">
80%
</div>
</div>
</div>
</body>
</html>
List Groups
List Groups are used to display a series of content in an organized way.
Use .list-group and .list-group-item classes to create a list of items. The .list-
group class is used with <ul> element and .list-group-item is used with <li>
element.
<!DOCTYPE html>
<html lang="en">
<head>
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<h1 style="color:green;text-align:center;">
List Component
</h1>
<div class="container">
<ul class="list-group">
<li class="list-group-item">
Data Structure
</li>
<li class="list-group-item">
Operating System
</li>
<li class="list-group-item">
Algorithm
</li>
</ul>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<h1 style="color:green;text-align:center;">
</h1>
<div class="container">
<h2>List Groups</h2>
<ul class="list-group">
Data Structure
</li>
<li class="list-group-item">
Operating System
</li>
<li class="list-group-item">
Algorithm
</li>
</ul>
</div>
</body>
</html>
Alerts
We often see certain alerts on some websites before or after completing an
action. These alert messages are highlighted texts that are important to take
into consideration while performing a process. Bootstrap allows showing
these alert messages on the website using predefined classes.
The .alert class followed by contextual classes are used to display the alert
message on website. The alert classes are: .alert-success, .alert-info, .alert-
warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light and .alert-
dark.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Alerts</title>
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
</head>
<body>
<h1 style="color:green;text-align:center;">
Alert Component
</h1>
<div class="container">
<strong>Success alert!</strong>
</div>
</div>
<strong>Warning alert!</strong>
</div>
<strong>Danger alert!</strong>
</div>
<strong>primary alert!</strong>
</div>
<strong>Secondary alert!</strong>
</div>
<strong>Light alert!</strong>
</div>
<strong>Dark alert!</strong>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Alerts</title>
</head>
<body>
<h1 style="color:green;text-align:center;">
Closing Alerts
</h1>
<div class="container">
<strong>Success alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>Info alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>Warning alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>Danger alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>primary alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>Secondary alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>Light alert!</strong>
data-dismiss="alert">
×
</button>
</div>
<strong>Dark alert!</strong>
data-dismiss="alert">
×
</button>
</div>
</div>
</body>
</html>