Bootstrap React List group

Bootstrap React List Group component allows displaying a series of content. Learn how to use react list group to build complex list structure on your website.

Basic example#

The default list group is an unordered list with items and the proper CSS classes. Build upon it with the options that follow, or with your CSS as required.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
1<CListGroup>
2 <CListGroupItem>Cras justo odio</CListGroupItem>
3 <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
4 <CListGroupItem>Morbi leo risus</CListGroupItem>
5 <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
6 <CListGroupItem>Vestibulum at eros</CListGroupItem>
7</CListGroup>

Active items#

Add active boolean property to a <CListGroupItem> to show the current active selection.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
1<CListGroup>
2 <CListGroupItem active>Cras justo odio</CListGroupItem>
3 <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
4 <CListGroupItem>Morbi leo risus</CListGroupItem>
5 <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
6 <CListGroupItem>Vestibulum at eros</CListGroupItem>
7</CListGroup>

Disabled items#

Add disabled boolean property to a <CListGroupItem> to make it appear disabled.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
1<CListGroup>
2 <CListGroupItem disabled>Cras justo odio</CListGroupItem>
3 <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
4 <CListGroupItem>Morbi leo risus</CListGroupItem>
5 <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
6 <CListGroupItem>Vestibulum at eros</CListGroupItem>
7</CListGroup>

Use <a>s or <button>s to create actionable list group items with hover, disabled, and active states by adding component="a|button". We separate these pseudo-classes to ensure list groups made of non-interactive elements (like <li>s or <div>s) don't provide a click or tap affordance.

1<CListGroup>
2 <CListGroupItem component="a" href="#" active>
3 Cras justo odio
4 </CListGroupItem>
5 <CListGroupItem component="a" href="#">
6 Dapibus ac facilisis in
7 </CListGroupItem>
8 <CListGroupItem component="a" href="#">
9 Morbi leo risus
10 </CListGroupItem>
11 <CListGroupItem component="a" href="#">
12 Porta ac consectetur ac
13 </CListGroupItem>
14 <CListGroupItem component="a" href="#" disabled>
15 Vestibulum at eros
16 </CListGroupItem>
17</CListGroup>
1<CListGroup>
2 <CListGroupItem component="button" active>
3 Cras justo odio
4 </CListGroupItem>
5 <CListGroupItem component="button">Dapibus ac facilisis in</CListGroupItem>
6 <CListGroupItem component="button">Morbi leo risus</CListGroupItem>
7 <CListGroupItem component="button">Porta ac consectetur ac</CListGroupItem>
8 <CListGroupItem component="button" disabled>
9 Vestibulum at eros
10 </CListGroupItem>
11</CListGroup>

Flush#

Add flush boolean property to remove some borders and rounded corners to render list group items edge-to-edge in a parent container (e.g., cards).

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
1<CListGroup flush>
2 <CListGroupItem>Cras justo odio</CListGroupItem>
3 <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
4 <CListGroupItem>Morbi leo risus</CListGroupItem>
5 <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
6 <CListGroupItem>Vestibulum at eros</CListGroupItem>
7</CListGroup>

Horizontal#

Add layout="horizontal" to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant .layout="horizontal-{sm|md|lg|xl|xxl}" to make a list group horizontal starting at that breakpoint's min-width. Currently horizontal list groups cannot be combined with flush list groups.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
1<>
2 {['', '-sm', '-md', '-lg', '-xl', '-xxl'].map((breakpoint, index) => (
3 <CListGroup className="mb-2" layout={`horizontal${breakpoint}`} key={index}>
4 <CListGroupItem>Cras justo odio</CListGroupItem>
5 <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
6 <CListGroupItem>Morbi leo risus</CListGroupItem>
7 </CListGroup>
8 ))}
9</>

Contextual classes#

Use contextual classes to style list items with a stateful background and color.

  • Dapibus ac facilisis in
  • A simple primary list group item
  • A simple secondary list group item
  • A simple success list group item
  • A simple danger list group item
  • A simple warning list group item
  • A simple info list group item
  • A simple light list group item
  • A simple dark list group item
1<CListGroup>
2 <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
3 {['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(
4 (color, index) => (
5 <CListGroupItem color={color} key={index}>
6 A simple {color} list group item
7 </CListGroupItem>
8 ),
9 )}
10</CListGroup>

Contextual classes also work with <a>s or <button>s. Note the addition of the hover styles here not present in the previous example. Also supported is the active state; apply it to indicate an active selection on a contextual list group item.

1<CListGroup>
2 <CListGroupItem component="a" href="#">
3 Dapibus ac facilisis in
4 </CListGroupItem>
5 {['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(
6 (color, index) => (
7 <CListGroupItem component="a" href="#" color={color} key={index}>
8 A simple {color} list group item
9 </CListGroupItem>
10 ),
11 )}
12</CListGroup>
Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the `.visually-hidden` class.

With badges#

Add badges to any list group item to show unread counts, activity, and more.

  • Cras justo odio14
  • Dapibus ac facilisis in2
  • Morbi leo risus1
1<CListGroup>
2 <CListGroupItem className="d-flex justify-content-between align-items-center">
3 Cras justo odio
4 <CBadge color="primary" shape="rounded-pill">
5 14
6 </CBadge>
7 </CListGroupItem>
8 <CListGroupItem className="d-flex justify-content-between align-items-center">
9 Dapibus ac facilisis in
10 <CBadge color="primary" shape="rounded-pill">
11 2
12 </CBadge>
13 </CListGroupItem>
14 <CListGroupItem className="d-flex justify-content-between align-items-center">
15 Morbi leo risus
16 <CBadge color="primary" shape="rounded-pill">
17 1
18 </CBadge>
19 </CListGroupItem>
20</CListGroup>

Custom content#

Add nearly any HTML within, even for linked list groups like the one below, with the help of flexbox utilities.

1<CListGroup>
2 <CListGroupItem component="a" href="#" active>
3 <div className="d-flex w-100 justify-content-between">
4 <h5 className="mb-1">List group item heading</h5>
5 <small>3 days ago</small>
6 </div>
7 <p className="mb-1">
8 Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
9 </p>
10 <small>Donec id elit non mi porta.</small>
11 </CListGroupItem>
12 <CListGroupItem component="a" href="#">
13 <div className="d-flex w-100 justify-content-between">
14 <h5 className="mb-1">List group item heading</h5>
15 <small className="text-medium-emphasis">3 days ago</small>
16 </div>
17 <p className="mb-1">
18 Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
19 </p>
20 <small className="text-medium-emphasis">Donec id elit non mi porta.</small>
21 </CListGroupItem>
22 <CListGroupItem component="a" href="#">
23 <div className="d-flex w-100 justify-content-between">
24 <h5 className="mb-1">List group item heading</h5>
25 <small className="text-medium-emphasis">3 days ago</small>
26 </div>
27 <p className="mb-1">
28 Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
29 </p>
30 <small className="text-medium-emphasis">Donec id elit non mi porta.</small>
31 </CListGroupItem>
32</CListGroup>

Checkboxes and radios#

Place Bootstrap React's checkboxes and radios within list group items and customize as needed.

1<CListGroup>
2 <CListGroupItem>
3 <CFormCheck label="Cras justo odio" />
4 </CListGroupItem>
5 <CListGroupItem>
6 <CFormCheck label="Dapibus ac facilisis in" defaultChecked />
7 </CListGroupItem>
8 <CListGroupItem>
9 <CFormCheck label="Morbi leo risus" defaultChecked />
10 </CListGroupItem>
11 <CListGroupItem>
12 <CFormCheck label="orta ac consectetur ac" />
13 </CListGroupItem>
14 <CListGroupItem>
15 <CFormCheck label="Vestibulum at eros" />
16 </CListGroupItem>
17</CListGroup>

And if you want <label>s as the .list-group-item for large hit areas, you can do that, too.

1<CListGroup>
2 <CFormCheck className="list-group-item" hitArea="full" label="Cras justo odio" />
3 <CFormCheck
4 className="list-group-item"
5 hitArea="full"
6 label="Dapibus ac facilisis in"
7 defaultChecked
8 />
9 <CFormCheck className="list-group-item" hitArea="full" label="Morbi leo risus" defaultChecked />
10 <CFormCheck className="list-group-item" hitArea="full" label="orta ac consectetur ac" />
11 <CFormCheck className="list-group-item" hitArea="full" label="Vestibulum at eros" />
12</CListGroup>

API#

CListGroup#

1import { CListGroup } from '@coreui/bootstrap-react'
2// or
3import CListGroup from '@coreui/bootstrap-react/src/components/list-group/CListGroup'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the component.string-
componentComponent used for the root node. Either a string to use a HTML element or a component.string | ComponentClass<any, any> | FunctionComponent<any>-
flushRemove some borders and rounded corners to render list group items edge-to-edge in a parent component (e.g., <CCard>).boolean-
layoutSpecify a layout type.'horizontal' | 'horizontal-sm' | 'horizontal-md' | 'horizontal-lg' | 'horizontal-xl' | 'horizontal-xxl'-

CListGroupItem#

1import { CListGroupItem } from '@coreui/bootstrap-react'
2// or
3import CListGroupItem from '@coreui/bootstrap-react/src/components/list-group/CListGroupItem'
PropertyDescriptionTypeDefault
activeToggle the active state for the component.boolean-
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of Bootstrap React’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-
componentComponent used for the root node. Either a string to use a HTML element or a component.string | ComponentClass<any, any> | FunctionComponent<any>li
disabledToggle the disabled state for the component.boolean-