Search...

ListGroup

React Bootstrap 5 ListGroup

React Bootstrap 5 List group is a versatile component that can display both simple and complex custom information.

Importing the React Bootstrap 5 ListGroup component

Start by importing CDBListGroup into your project to use the Contrast React Bootstrap 5 ListGroup component. Then you import the CDBListGroupItem for the list group's items.

js
import { CDBListGroup, CDBListGroupItem } from "cdbreact";

Default ListGroup

  • List Group
  • List Group
  • List Group
  • List Group
  • List Group
js
import React from "react";
import { CDBListGroup, CDBListGroupItem, CDBContainer } from "cdbreact";
const LIstGroup = () => {
return (
<CDBContainer>
<CDBListGroup style={{ width: "30rem" }}>
<CDBListGroupItem>List Group </CDBListGroupItem>
<CDBListGroupItem>List Group</CDBListGroupItem>
<CDBListGroupItem>List Group</CDBListGroupItem>
<CDBListGroupItem>List Group</CDBListGroupItem>
<CDBListGroupItem>List Group</CDBListGroupItem>
<CDBListGroupItem>List Group</CDBListGroupItem>
</CDBListGroup>
</CDBContainer>
);
};
export default LIstGroup;

The href attribute on the CDBLIstGroupItem makes the list group item behave as a Link element.

  • List Group
  • List Group
  • List Group
  • List Group
  • List Group Link
  • List Group
js
import React from "react";
import { CDBListGroup, CDBListGroupItem, CDBContainer } from "cdbreact";
const ListGroup = () => {
return (
<CDBContainer>
<CDBListGroup style={{ width: "30rem" }}>
<CDBListGroupItem active>List Group</CDBListGroupItem>
<CDBListGroupItem hover>List Group</CDBListGroupItem>
<CDBListGroupItem hover>List Group</CDBListGroupItem>
<CDBListGroupItem hover>List Group</CDBListGroupItem>
<CDBListGroupItem hover>List Group</CDBListGroupItem>
<CDBListGroupItem hover>List Group</CDBListGroupItem>
</CDBListGroup>
</CDBContainer>
);
};
export default ListGroup;

Label

In this part of the tutorial we imported a component CDBBadge alongside CDBListGroup and the CDBLIstGroupItem.

List Group
19
List Group
19
List Group
19
List Group
19
List Group
19
List Group
19
js
import React from "react";
import { CDBListGroup, CDBListGroupItem, CDBBadge, CDBContainer } from "cdbreact";
const LIstGroup = () => {
return (
<CDBContainer>
<CDBListGroup style={{ width: "30rem" }}>
<CDBListGroupItem className="d-flex justify-content-between align-items-center">
List Group <CDBBadge color="primary">19</CDBBadge>
</CDBListGroupItem>
<CDBListGroupItem className="d-flex justify-content-between align-items-center">
List Group
<CDBBadge color="secondary">19</CDBBadge>
</CDBListGroupItem>
<CDBListGroupItem className="d-flex justify-content-between align-items-center">
List Group
<CDBBadge color="success">19</CDBBadge>
</CDBListGroupItem>
<CDBListGroupItem className="d-flex justify-content-between align-items-center">
List Group
<CDBBadge color="danger">19</CDBBadge>
</CDBListGroupItem>
<CDBListGroupItem className="d-flex justify-content-between align-items-center">
List Group<CDBBadge color="info">19</CDBBadge>
</CDBListGroupItem>
<CDBListGroupItem className="d-flex justify-content-between align-items-center">
List Group<CDBBadge color="warning">19</CDBBadge>
</CDBListGroupItem>
</CDBListGroup>
</CDBContainer>
);
};
export default LIstGroup;

Color List Group

The background color of the CDBListGroupItem is influenced by the color prop.

  • List Group
  • List Group
  • List Group
  • List Group
  • List Group Link
  • List Group
js
import React from "react";
import { CDBListGroup, CDBListGroupItem, CDBContainer } from "cdbreact";
const LIstGroup = () => {
return (
<CDBContainer>
<CDBListGroup style={{ width: "30rem" }}>
<CDBListGroupItem color="primary">List Group </CDBListGroupItem>
<CDBListGroupItem color="secondary">List Group</CDBListGroupItem>
<CDBListGroupItem color="success">List Group</CDBListGroupItem>
<CDBListGroupItem color="danger">List Group</CDBListGroupItem>
<CDBListGroupItem color="info">List Group Link</CDBListGroupItem>
<CDBListGroupItem color="warning">List Group</CDBListGroupItem>
</CDBListGroup>
</CDBContainer>
);
};
export default LIstGroup;

Icons

Pro Component

You can have icons in your list group items by nesting a CDBIcon component in a CDBLIstGroupItem. However, only pro users have access to this feature.

List Group
List Group
List Group
List Group
List Group
List Group
js
import React from "react";
import { CDBListGroup, CDBListGroupItem, CDBIcon, CDBContainer } from "cdbreact";
const LIstGroup = () => {
return (
<CDBContainer>
<CDBListGroup style={{ width: "30rem" }}>
<CDBListGroupItem>
<CDBIcon fab icon="facebook" className="me-3" />
List Group
</CDBListGroupItem>
<CDBListGroupItem>
<CDBIcon fab icon="facebook" size="2x" className="me-3" />
List Group
</CDBListGroupItem>
<CDBListGroupItem>
<CDBIcon fab icon="facebook" size="2x" className="me-3" />
List Group
</CDBListGroupItem>
<CDBListGroupItem>
<CDBIcon fab icon="facebook" size="2x" className="me-3" />
List Group
</CDBListGroupItem>
<CDBListGroupItem>
<CDBIcon fab icon="facebook" size="2x" className="me-3" />
List Group
</CDBListGroupItem>
<CDBListGroupItem>
<CDBIcon fab icon="facebook" size="2x" className="me-3" />
List Group
</CDBListGroupItem>
</CDBListGroup>
</CDBContainer>
);
};
export default LIstGroup;

API

This section will explain the props available with the Contrast React Bootstrap 5 ListGroup component. You will discover what these props do, their default values, and how you would use them in your code.

API Reference: Contrast React Bootstrap 5 ListGroup Props

Other CDBListGroup component prop options are listed in the table below.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBLIstGroup className="myClass" ... />
tagfunction or StringulChanges default input tag<CDBLIstGroup tag="ul" ... />

API Reference: Contrast React Bootstrap 5 LIstGroupItem Properties

Other prop options for the CDBListGroupItem component are listed in the table below.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBLIstGroupItem className="myClass" ... />
tagfunction or StringliChanges default input tag<CDBLIstGroupItem tag="li" ... />
activeBooleanfalseAdds default active state to item<CDBLIstGroupItem active .../>
colorStringChanges Item background and text color, accepts ["primary", "default", "secondary", "success", "dark", "danger", "info", "warning", "white" ]<CDBLIstGroupItem color="primary" ... />
disableBooleanfalseDisables item from being clicked<CDBLIstGroupItem disabled .../>
hoverBooleanfalseAdds hover effect (slightly background color change)<CDBLIstGroupItem hover .../>

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.