The Wayback Machine - https://web.archive.org/web/20250303204202/https://www.geeksforgeeks.org/bootstrap-5-list-group/
Open In App

Bootstrap 5 List group

Last Updated : 15 Mar, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

Bootstrap 5 is the latest major release by Bootstrap in which they have revamped the UI and made various changes. List groups are a flexible and powerful component for displaying a series of content. These can be modified and extended to support just about any content within. 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.

Syntax:

<div class="list-group"> Contents... <div>

List group

The .list-group class is used with <ul> element and .list-group-item is used with <li> element.

Syntax:

<ul class="list-group">
<li class="list-group-item">An item</li>
<li class="list-group-item active" aria-current="true">An active item</li>
<li class="list-group-item disabled" aria-disabled="true">A disabled item</li>
<a href="#" class="list-group-item list-group-item-action active" aria-current="true">
The current link item
</a>
</ul>

Example: This example demonstrates creating a list using list-group-item.

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <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>

Output:

Active list item

The .active class is used to highlight the current item. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <ul class="list-group">
            <li class="list-group-item active">
                Data Structure
            </li>
            <li class="list-group-item">
                Operating System
            </li>
            <li class="list-group-item">
                Algorithm
            </li>
        </ul>
    </div>
</body>
</html>

Output:

List Group With Linked Items

Use <div> and <a> tag instead of <ul> and <li> to create a list of group with linked items. The .list-group-item-action class is used to set the hover effect to change the background color to gray. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <div class="container">
            <div class="list-group">
                <a href="#" class="list-group-item
                            list-group-item-action">
                    Data Structure
                </a>
                <a href="#" class="list-group-item
                            list-group-item-action">
                    Operating System
                </a>
                <a href="#" class="list-group-item
                            list-group-item-action">
                    Algorithm
                </a>
            </div>
        </div>
    </div>
</body>
</html>

Output:

Disabled Item

The .disabled class is used to disable the text content. This class set the text color to light. When used on links, it will remove the hover effect.

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3" style="width: 700px;">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <div class="container">
            <div class="list-group">
                <a href="#" class="list-group-item disabled">
                    Android
                </a>
                <a href="#" class="list-group-item">
                    Web
                </a>
                <a href="#" class="list-group-item disabled">
                    AI
                </a>
            </div>
        </div>
    </div>
</body>
</html>

Output:

Flush/Remove Borders

The .list-group-flush class is used to remove some borders and rounded corners. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <div class="container">
            <ul class="list-group
                    list-group-flush">
                <a href="#" class="list-group-item">
                    Android
                </a>
                <a href="#" class="list-group-item">
                    Web
                </a>
                <a href="#" class="list-group-item">
                    AI
                </a>
            </ul>
        </div>
    </div>
</body>
</html>

Output:

Horizontal List Groups

The .list-group-horizontal class is used to display the list of items horizontally instead of vertically. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <div class="container">
            <ul class="list-group
                    list-group-horizontal">
                <a href="#" class="list-group-item">
                    Android
                </a>
                <a href="#" class="list-group-item">
                    Web
                </a>
                <a href="#" class="list-group-item">
                    AI
                </a>
            </ul>
        </div>
    </div>
</body>
</html>

Output:

Contextual Classes

It is used to set the color to the list of items. The classes for coloring the list-items are: .list-group-item-success, .list-group-item-secondary, .list-group-item-info, .list-group-item-warning, .list-group-item-danger, .list-group-item-primary, .list-group-item-dark and .list-group-item-light. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <ul class="list-group">
            <li class="list-group-item
                        list-group-item-primary">
                Web
            </li>
            <li class="list-group-item
                        list-group-item-secondary">
                Android
            </li>
            <li class="list-group-item
                        list-group-item-success">
                AI
            </li>
            <li class="list-group-item
                        list-group-item-warning">
                Data Science
            </li>
            <li class="list-group-item
                        list-group-item-danger">
                UI/UX
            </li>
        </ul>
    </div>
</body>
</html>

Output:

The contextual classes can be used with list of items. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <ul class="list-group">
            <a class="list-group-item
                        list-group-item-primary">
                Web
            </a>
            <a class="list-group-item
                        list-group-item-secondary">
                Android
            </a>
            <a class="list-group-item
                        list-group-item-success">
                AI
            </a>
            <a class="list-group-item
                        list-group-item-warning">
                Data Science
            </a>
            <a class="list-group-item
                        list-group-item-danger">
                UI/UX
            </a>
        </ul>
    </div>
</body>
</html>

Output:

List Group with Badges

The .badge class can be combined with the utility class to add badges inside the list of groups. 

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous">
    </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous">
    </script>
</head>
<body class="text-center">
    <div class="container mt-3">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <ul class="list-group">
            <li class="list-group-item
                        d-flex
                        justify-content-between
                        align-items-center">
                    CPP
                <span class="badge bg-success">
                    X
                </span>
            </li>
            <li class="list-group-item
                        d-flex
                        justify-content-between
                        align-items-center">
                Python
                <span class="badge bg-success">
                    Y
                </span>
            </li>
            <li class="list-group-item d-flex
                        justify-content-between
                        align-items-center">
                JavaScript
                <span class="badge bg-success">
                    Z
                </span>
            </li>
        </ul>
    </div>
</body>
</html>

Output:


Become a Full-Stack Developer and also get 90% fee refund on completing 90% course in 90 days! Take the Three 90 Challenge today.

After successfully processing refunds worth over INR 5 Cr, GeeksforGeeks is back with the Three 90 challenge and this is your chance to upskill and get 90% refund. What more motivation do you need? Start the challenge right away!


Next Article

Similar Reads

List group in bootstrap with examples
List Groups are used to display a series of content. We can modify them to support any content as per our needs. The use of List-Groups is just to display a series or list of content in an organized way. Below is a basic List Group created using unordered_lists in HTML, and appropriate Bootstrap classes: HTML <!DOCTYPE html> <html>
4 min read
Bootstrap 5 List group Horizontal
Bootstrap 5 List group Horizontal facilitates to modification & alignment of the structure of the list group items from vertical to horizontal, across all breakpoints, by implementing the .list-group-horizontal class. In order to create a list group horizontal that starts with the min-width of the breakpoint, we can implement the .list-group-ho
2 min read
Bootstrap 5 List group Checkboxes and radios
Bootstrap 5 List group Checkboxes and radios use .list-group and .list-group-item classes to create a list of items. The .list-group class is used with <ul> element and the .list-group-item is used with <li> element. Then create the checkbox and radios in the input element using the type attribute. Note: In situations where the element'
2 min read
Bootstrap 5 List group Contextual classes
Bootstrap 5 List group Contextual classes are used to style list-group-items with different backgrounds and colors. Bootstrap 5 List group Contextual Used Classes: list-group-item-primary: For blue color styling of the list itemlist-group-item-success: For green color styling of the list itemlist-group-item-secondary: For grey color styling of the
2 min read
Bootstrap 5 List group getInstance() Method
Bootstrap 5 List Group getInstance() method is used to get the instance of the tab attached with the DOM element passes as the parameter. This method returns the instance that can later be used to perform different operations like triggering other methods on the Tab pane.Syntax:const element = document.querySelector("#listItem-ID");element.getInsta
4 min read
Bootstrap 5 List group show() Method
Bootstrap 5 List Group shows a series of content to the user. The show() method of the list group selects the given item and shows its corresponding pane and the previously selected list item becomes unselected and the pane of the previously selected item's pane becomes hidden. The show() method returns to the caller before the actual list item is
4 min read
Bootstrap 5 Scrollspy with list-group
Bootstrap 5, Bootstrap Scrollspy is a feature that automatically updates navigation links based on scroll position. It's particularly useful for long content-heavy pages where we want to keep the user informed about their current section in the document.Bootstrap 5 Scrollspy with list-group classes: There is no specific class used to scrollspy with
4 min read
What is the use of the list-group Class in Bootstrap?
The .list-group class in Bootstrap is utilized to create a stylized list of items, often used for navigation menus, item lists, or other grouped content. It allows developers to display a collection of items in a visually appealing and organized manner, with optional additional components such as badges or icons. Syntax:<ul class="list-group"
1 min read
How to add badge to list group in Bootstrap ?
In this article, we will learn how to make a badge list that gives the idea on a priority basis of the list. List Groups are used to display series of content. We can use the List Groups to display a series or list of content in an organized way & this can be helpful as we can modify it as per our needs. Badges are the number label that is ass
3 min read
Bootstrap 5 List group Flush
Bootstrap 5 provides the List Group Flush feature in which items are stored in the form of a list. List groups are a flexible and powerful component for displaying a series of content. The List Group Flush feature is used to remove borders and rounded corners around the items on the list. List group Flush Class: list-group-flush: This class is used
2 min read