Bootstrap list group is basically an unordered list with list items.
Example
Steps: to create bootstrap 5 list group:
.list-group
to the unordered list
<ul>
element base class.
list-item
to the unordered list item <li>
element base class. Source Code
<div class="container mt-5">
<div class="row">
<div class="col-sm-6 offset-sm-3">
<ul class="list-group">
<li class="list-group-item">First List item</li>
<li class="list-group-item">Second List item</li>
<li class="list-group-item">Third List item</li>
</ul>
</div> <!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note: To create a list group, you have to assign .list-group
to the
list group container while assign .list-group-item
to the child element of list group container
To display the active item of the list group, add .active
to the list item having .list-group-item
.
Example
General Syntax
<ul class="list-group">
<li class="list-group-item active">List Item</li>
</ul>
Source Code
<div class="container">
<p class="text-center">Bootstrap List Group:Active Item</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<ul class="list-group">
<li class="list-group-item active">Learn HTML</li>
<li class="list-group-item">Learn CSS</li>
<li class="list-group-item">Learn Bootstrap</li>
</ul>
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note: To create active list-item ,assign .active
to the list-item base class.
To make disabled list item, add .disabled
to the list item having .list-group-item
.
Example
General Syntax
<ul class="list-group">
<li class="list-group-item disabled">List Item</li>
</ul>
Source Code
<div class="container">
<p class="text-center">Bootstrap List Group:Disabled Item</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<ul class="list-group">
<li class="list-group-item disabled">Learn HTML</li>
<li class="list-group-item">Learn CSS</li>
<li class="list-group-item">Learn Bootstrap</li>
</ul>
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note:
In this example,.disabled
is assigned to the list-item base class to create a disabled list item.
Steps to create bootstrap 5 actionable list item.
<div>
in place of <ul>
and <a>
in place of <li>
. .list-group
to the <div>
base class. .list-group-item
to the <a>
base class. .list-group-item
to the <a>
base class. .list-group-item-action
to the element having list-group-item
class. Example
General Syntax
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action"> List Item </a>
</div>
Source Code
<div class="container mt-5">
<p class="text-center">List Group With Linked Items</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">Web Design</a>
<a href="#" class="list-group-item list-group-item-action">Graphics Design</a>
<a href="#" class="list-group-item list-group-item-action">Web Hosting</a>
</div> <!--/list-group-->
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note:In this example, an actionable list item has been created by applying above mentioned steps.
To create active actionable list item, use .active
class to <a>
element base class.it will remove the hover effect of an actionable list items.
Example
General Syntax
<div class="list-group">
<a href="#" class="list-group-item active">Active Link Item</a>
</div>
Source Code
<div class="container mt-5">
<p class="text-center mt-4 mb-4">List Group With Active Linked Items</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="list-group">
<a href="#" class="list-group-item active">Web Design</a>
<a href="#" class="list-group-item">App Design</a>
<a href="#" class="list-group-item active">Graphics Design</a>
</div><!--/list-group-->
</div><!--/col-sm-6-->
</div> <!--/row-->
</div><!--/container-->
Code Explanation
Note: In this example, an active actionable list item has been created by assigning .active
to the <a>
element base class.
To create a disabled actionable list item, use the .disabled
class to the <a>
element base class.It will remove the hover effect on actionable list items.
Example
General Syntax
<div class="list-group">
<a href="#" class="list-group-item disabled">Disabled Linked Item</a>
</div>
Source Code
<div class="container">
<p class="text-center">List Group With Disabled Linked Items</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="list-group">
<a href="#" class="list-group-item disabled">Web Design</a>
<a href="#" class="list-group-item">App Design</a>
<a href="#" class="list-group-item disabled">Graphics Design</a>
</div><!--/list-group-->
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note: In this example, disabled actionable list item has been created by assigning .disabled
to the <a>
element base class.
Apply the list-group-flush
class to the <ul>
element base class that removes some borders and rounded corners of the list items.
Source Code
<div class="container mt-5">
<p class="text-center">List Group Flush</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<ul class="list-group list-group-flush">
<li class="list-group-item">First item</li>
<li class="list-group-item">Second item</li>
<li class="list-group-item">Third item</li>
<li class="list-group-item">Fourth item</li>
</ul>
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note: Bootstrap list group flush is used to remove some corners and borders of the list items.
To create a horizontal list group, add list-group-horizontal
class to the <ul>
element base class. A horizontal list can also be created with respect to device breakpoints. You have to use the list-group-horizontal-{sm|md|lg|xl}
class to the <ul>
element base class that makes a list group horizontal starting at those breakpoints min-width.
Use flex-fill
class to every list item to make equal width of the horizontal list item.
Source Code
<div class="container mt-5">
<p class="mb-4">Horizontal List Group At The Medium Device Breakpoint.</p>
<ul class="list-group list-group-horizontal-md">
<li class="list-group-item">Web Design</li>
<li class="list-group-item">Web Development</li>
<li class="list-group-item">Graphics Design</li>
</ul>
<p class="mt-5 mb-4">Horizontal List Group At The Small Device Breakpoint.</p>
<ul class="list-group list-group-horizontal-sm">
<li class="list-group-item">Learn HTML</li>
<li class="list-group-item">Learn CSS</li>
<li class="list-group-item">Learn Bootstrap</li>
</ul>
</div>
Code Explanation
Note:A horizontal list group is created by assigning either .list-group-horizontal
or list-group-horizontal-{sm|md|lg|xl}
class to the list group container (<ul>
) element base class.
Bootstrap provides a contextual class that provides additional color as well as a background color to the list item.
Followings are the contextual classes that are very useful for coloring the list item. These are .list-group-item-success
,.list-group-item-secondary
,.list-group-item-info
,.list-group-item-warning
,.list-group-item-danger
, .list-group-item-dark
and .list-group-item-light
.
General Syntax
<ul class="list-group">
<li class="list-group-item list-group-item-{success | secondary | info | warning | danger | dark | light}">List Group</li>
</ul>
Source Code
<div class="container">
<p class="text-center">List Group Contextual Classes</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<ul class="list-group">
<li class="list-group-item">Tutorials</li>
<li class="list-group-item list-group-item-primary">Web Design</li>
<li class="list-group-item list-group-item-secondary">Graphics Design</li>
<li class="list-group-item list-group-item-success">App Design</li>
</ul>
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note: To provide different background colors to the list group, use list group, contextual classes.
General Syntax
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action list-group-item-{success | secondary info ..}">Action item</a>
</div>
Source Code
<div class="container mt-5">
<p class="text-center">List Group Link Item With Contextual Classes</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">Action item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-success">Success item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-secondary">Secondary item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-info">Info item</a>
</div>
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->
Code Explanation
Note: Assign List group contextual class to the linked item base class to provide different background colors to the list item.
General Syntax
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Inbox <span class="badge bg-secondary badge-pill">85</span>
</li>
</ul>
Source Code
<div class="container mt-5">
<p class="text-center"> List Group With Badge</p>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Inbox
<span class="badge bg-secondary badge-pill">85</span>
</li>
</ul>
</div><!--/col-sm-6-->
</div><!--/row-->
</div><!--/container-->