Bootstrap 5 List group SASS
Last Updated :
01 Aug, 2024
Bootstrap 5 List Group SASS can be used to change the default values provided for the list group by customizing scss file of bootstrap 5.
SASS variables of List Group:
- $list-group-color: This variable provides the text color of the list group. By default, it is gray color.
- $list-group-bg: This variable provides the background color of the list group. By default, it is white color.
- $list-group-border-color: This variable provides the border color of the list group. By default, it is black color with an opacity of 0.125
- $list-group-border-width: This variable provides the border width of the list group. By default, it is 1px.
- $list-group-border-radius: This variable provides the border radius of the list group. By default, it is 0.375rem.
- $list-group-item-padding-y: This variable provides the top and bottom padding of the item in the list group. By default, it is 0.5rem
- $list-group-item-padding-x: This variable provides the left and right padding of the item in the list group. By default, it is 1rem
- $list-group-item-bg-scale: This variable provides the contrast of the background color of the list group item. By default, it is -80%
- $list-group-item-color-scale: This variable provides the contrast of the text color of the list group item. By default, it is 40%
- $list-group-hover-bg: This variable provides the background color of the list group on hover. By default, it is gray color.
- $list-group-active-color: This variable provides the text color of the list group item which is active. By default, it is white color.
- $list-group-active-bg: This variable provides the background color of the list group item which is active. By default, it is blue color.
- $list-group-active-border-color: This variable provides the border color of the list group item which is active. By default, it is blue color.
- $list-group-disabled-color: This variable provides the text color of the list group item which is disabled. By default, it is gray color.
- $list-group-disabled-bg: This variable provides the background color of the list group item which is disabled. By default, it is white color.
- $list-group-action-color: This variable provides the text color of the actionable list group. By default, it is gray color.
- $list-group-action-hover-color: This variable provides the text color of the actionable list group on hover. By default, it is gray color.
- $list-group-action-active-color: This variable provides the text color of the actionable list group on active. By default, it is white color.
- $list-group-action-active-bg: This variable provides the background color of the actionable list group which is active. By default, it is gray color.
Steps to override scss of Bootstrap:
Step 1: Install bootstrap using following command:
npm i bootstrap
Step 2: Create your custom scss file and write the variable you want to override. Then include the bootstrap scss file using import.
$class_to_override: values;
@import "node_modules/bootstrap/scss/bootstrap"
Step 3: Convert the file to CSS using live server extension.
Step 4: Include the converted scss file to your HTML after the link tag of Bootstrap css
Project Structure: Here the custom scss file name is “custom.scss” and custom.css is converted file
Syntax:
$variable:value;
@import "./node_modules/bootstrap/scss/bootstrap"
Example 1: In this example, making use of some of the above variables.
custom.scss
SCSS
$list-group-color:white;
$list-group-bg:green;
$list-group-border-color:black;
$list-group-border-width:5px;
$list-group-border-radius:2rem;
$list-group-item-padding-y:1rem;
$list-group-hover-bg:rgba(green,0.8);
$list-group-active-color:white;
$list-group-active-bg:black;
$list-group-active-border-color:black;
$list-group-disabled-color:rgba(black,0.7);
$list-group-disabled-bg:rgb(153, 238, 153);
$list-group-action-hover-color:black;
@import "./node_modules/bootstrap/scss/bootstrap"
CSS file created after conversion
custom.css
CSS
.list-group {
--bs-list-group-color: white;
--bs-list-group-bg: green;
--bs-list-group-border-color: black;
--bs-list-group-border-width: 5px;
--bs-list-group-border-radius: 2rem;
--bs-list-group-item-padding-x: 1rem;
--bs-list-group-item-padding-y: 1rem;
--bs-list-group-action-color: #495057;
--bs-list-group-action-hover-color: black;
--bs-list-group-action-hover-bg: rgba(0, 128, 0, 0.8);
--bs-list-group-action-active-color: #212529;
--bs-list-group-action-active-bg: #e9ecef;
--bs-list-group-disabled-color: rgba(0, 0, 0, 0.7);
--bs-list-group-disabled-bg: rgb(153, 238, 153);
--bs-list-group-active-color: white;
--bs-list-group-active-bg: black;
--bs-list-group-active-border-color: black;
display: flex;
flex-direction: column;
padding-left: 0;
margin-bottom: 0;
border-radius: var(--bs-list-group-border-radius);
}
index.html
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Bootstrap 5 List Group SASS</title>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
<link rel="stylesheet" href="./custom.css">
<script src=
"node_modules/bootstrap/dist/js/bootstrap.js">
</script>
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js">
</script>
</head>
<body class="text-center">
<div class="container">
<h1 class="text-success">GeeksforGeeks</h1>
<h5 class="text-success">Bootstrap 5 List Group SASS</h5>
<div class="container pt-3" style="width:850px;">
<ul class="list-group">
<li class="list-group-item">Java</li>
<li class="list-group-item disabled">C++</li>
<li class="list-group-item">Python</li>
<li class="list-group-item">Javascript</li>
</ul>
<h6 class="pt-3">List group with action</h6>
<div class="list-group">
<a href="#" class="list-group-item
list-group-item-action active">
Maths
</a>
<a href="#" class="list-group-item
list-group-item-action">
Science
</a>
<a href="#" class="list-group-item
list-group-item-action">
History
</a>
</div>
</div>
</div>
</body>
</html>
Output:
Example 2: In this example, making use of some of the above variables.
custom.scss
SCSS
$list-group-action-color:green;
$list-group-action-active-color:black;
$list-group-action-active-bg:green;
@import "./node_modules/bootstrap/scss/bootstrap"
CSS file created after conversion
custom.css
CSS
.list-group {
--bs-list-group-color: #212529;
--bs-list-group-bg: #fff;
--bs-list-group-border-color: rgba(0, 0, 0, 0.125);
--bs-list-group-border-width: 1px;
--bs-list-group-border-radius: 0.375rem;
--bs-list-group-item-padding-x: 1rem;
--bs-list-group-item-padding-y: 0.5rem;
--bs-list-group-action-color: green;
--bs-list-group-action-hover-color: green;
--bs-list-group-action-hover-bg: #f8f9fa;
--bs-list-group-action-active-color: black;
--bs-list-group-action-active-bg: green;
--bs-list-group-disabled-color: #6c757d;
--bs-list-group-disabled-bg: #fff;
--bs-list-group-active-color: #fff;
--bs-list-group-active-bg: #0d6efd;
--bs-list-group-active-border-color: #0d6efd;
display: flex;
flex-direction: column;
padding-left: 0;
margin-bottom: 0;
border-radius: var(--bs-list-group-border-radius);
}
index.html
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Bootstrap 5 List Group SASS</title>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
<link rel="stylesheet" href="./custom.css">
<script src=
"node_modules/bootstrap/dist/js/bootstrap.js">
</script>
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js">
</script>
</head>
<body class="text-center">
<div class="container">
<h1 class="text-success">GeeksforGeeks</h1>
<h5 class="text-success">Bootstrap 5 List Group SASS</h5>
<div class="container pt-3" style="width:850px;">
<h6>List group with action</h6>
<div class="list-group">
<a href="#" class="list-group-item
list-group-item-action active">
Maths
</a>
<a href="#" class="list-group-item
list-group-item-action">
Science
</a>
<a href="#" class="list-group-item
list-group-item-action">
History
</a>
<a href="#" class="list-group-item
list-group-item-action">
Geography
</a>
</div>
</div>
</div>
</body>
</html>
Output:
Reference: https://getbootstrap.com/docs/5.0/components/list-group/#sass
Similar Reads
Bootstrap 5 List group Active items Bootstrap 5 provides the List Group Active feature in which items are stored in form of a list. List groups are a flexible and powerful component for displaying a series of content. The List Group Active feature is used to indicate the currently active selection. List group Active items classes: .ac
2 min read
Bootstrap 5 List group Disabled items Bootstrap 5 provides the List Group disabled items feature in which items are stored in form of a list. List groups are a flexible and powerful component for displaying a series of content. The List Group Disabled items feature is used to indicate the item is currently disabled. List Group Disabled
2 min read
Bootstrap 5 List group Links and buttons Bootstrap 5 provides the List Group Links and Buttons items feature in which items are actionable and stored in form of a list. List groups are a flexible and powerful component for displaying a series of content. The List Group Links and Buttons items feature is used to indicate the item is current
2 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
2 min read
Bootstrap 5 List group Numbered Bootstrap 5 List Group Numbered is one of the capabilities offered by List Group in Bootstrap 5, which is used to keep items in the form of a list and display them sequentially through the use of numbers. List Group Numbered Classes: list-group-item: This class is used to indicate and add the items
2 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 t
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-gr
2 min read
Bootstrap 5 List group with badges Bootstrap 5 List group with badges can be used to add badges to the list group item to indicate the count of objects. List group With badges Classes: No special classes are used in the List group With badges. You can customize the list using .badge classes and style them with flex. Bootstrap 5 List
2 min read
Bootstrap 5 List group Custom content Bootstrap 5 List Group Custom content allows us to use HTML inside the list, here, the term "Custom Content" refers to HTML, therefore any HTML elements can be used inside, including anchor tags, paragraph tags, divs, photos, and many more.Bootstrap 5 List Group Custom content Classes: There is no p
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
2 min read