---
title: React List Group Component
name: List group
description: 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.
menu: Components
route: /components/list-group
other_frameworks: list-group
---

import {
  CBadge,
  CFormCheck,
  CListGroup,
  CListGroupItem,
  CLink,
} from '@coreui/react/src/index'

## 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.

```jsx preview
<CListGroup>
  <CListGroupItem>Cras justo odio</CListGroupItem>
  <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
  <CListGroupItem>Morbi leo risus</CListGroupItem>
  <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
  <CListGroupItem>Vestibulum at eros</CListGroupItem>
</CListGroup>
```

## Active items

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

```jsx preview
<CListGroup>
  <CListGroupItem active>Cras justo odio</CListGroupItem>
  <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
  <CListGroupItem>Morbi leo risus</CListGroupItem>
  <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
  <CListGroupItem>Vestibulum at eros</CListGroupItem>
</CListGroup>
```

## Disabled items

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

```jsx preview
<CListGroup>
  <CListGroupItem disabled>Cras justo odio</CListGroupItem>
  <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
  <CListGroupItem>Morbi leo risus</CListGroupItem>
  <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
  <CListGroupItem>Vestibulum at eros</CListGroupItem>
</CListGroup>
```

## Links and buttons

Use `<a>`s or `<button>`s to create _actionable_ list group items with hover, disabled, and active states by adding `as="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.

```jsx preview
<CListGroup>
  <CListGroupItem as="a" href="#" active>
    Cras justo odio
  </CListGroupItem>
  <CListGroupItem as="a" href="#">
    Dapibus ac facilisis in
  </CListGroupItem>
  <CListGroupItem as="a" href="#">
    Morbi leo risus
  </CListGroupItem>
  <CListGroupItem as="a" href="#">
    Porta ac consectetur ac
  </CListGroupItem>
  <CListGroupItem as="a" href="#" disabled>
    Vestibulum at eros
  </CListGroupItem>
</CListGroup>
```

```jsx preview
<CListGroup>
  <CListGroupItem as="button" active>
    Cras justo odio
  </CListGroupItem>
  <CListGroupItem as="button">Dapibus ac facilisis in</CListGroupItem>
  <CListGroupItem as="button">Morbi leo risus</CListGroupItem>
  <CListGroupItem as="button">Porta ac consectetur ac</CListGroupItem>
  <CListGroupItem as="button" disabled>
    Vestibulum at eros
  </CListGroupItem>
</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).

```jsx preview
<CListGroup flush>
  <CListGroupItem>Cras justo odio</CListGroupItem>
  <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
  <CListGroupItem>Morbi leo risus</CListGroupItem>
  <CListGroupItem>Porta ac consectetur ac</CListGroupItem>
  <CListGroupItem>Vestibulum at eros</CListGroupItem>
</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.**

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

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

## Contextual classes

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

<Example>
  <CListGroup>
    <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
    {['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(
      (color, index) => (
        <CListGroupItem color={color} key={index}>
          A simple {color} list group item
        </CListGroupItem>
      ),
    )}
  </CListGroup>
</Example>

```jsx
<CListGroup>
  <CListGroupItem>Dapibus ac facilisis in</CListGroupItem>
  {['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(
    (color, index) => (
      <CListGroupItem color={color} key={index}>
        A simple {color} list group item
      </CListGroupItem>
    ),
  )}
</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.

<Example>
  <CListGroup>
    <CListGroupItem as="a" href="#">
      Dapibus ac facilisis in
    </CListGroupItem>
    {['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(
      (color, index) => (
        <CListGroupItem as="a" href="#" color={color} key={index}>
          A simple {color} list group item
        </CListGroupItem>
      ),
    )}
  </CListGroup>
</Example>

```jsx
<CListGroup>
  <CListGroupItem as="a" href="#">
    Dapibus ac facilisis in
  </CListGroupItem>
  {['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(
    (color, index) => (
      <CListGroupItem as="a" href="#" color={color} key={index}>
        A simple {color} list group item
      </CListGroupItem>
    ),
  )}
</CListGroup>
```

<Callout color="info" title="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.
</Callout>

## With badges

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

```jsx preview
<CListGroup>
  <CListGroupItem className="d-flex justify-content-between align-items-center">
    Cras justo odio
    <CBadge color="primary" shape="rounded-pill">
      14
    </CBadge>
  </CListGroupItem>
  <CListGroupItem className="d-flex justify-content-between align-items-center">
    Dapibus ac facilisis in
    <CBadge color="primary" shape="rounded-pill">
      2
    </CBadge>
  </CListGroupItem>
  <CListGroupItem className="d-flex justify-content-between align-items-center">
    Morbi leo risus
    <CBadge color="primary" shape="rounded-pill">
      1
    </CBadge>
  </CListGroupItem>
</CListGroup>
```

## Custom content

Add nearly any HTML within, even for linked list groups like the one below, with the help of [flexbox utilities](https://coreui.io/docs/utilities/flex/).

```jsx preview
<CListGroup>
  <CListGroupItem as="a" href="#" active>
    <div className="d-flex w-100 justify-content-between">
      <h5 className="mb-1">List group item heading</h5>
      <small>3 days ago</small>
    </div>
    <p className="mb-1">
      Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
    </p>
    <small>Donec id elit non mi porta.</small>
  </CListGroupItem>
  <CListGroupItem as="a" href="#">
    <div className="d-flex w-100 justify-content-between">
      <h5 className="mb-1">List group item heading</h5>
      <small className="text-body-secondary">3 days ago</small>
    </div>
    <p className="mb-1">
      Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
    </p>
    <small className="text-body-secondary">Donec id elit non mi porta.</small>
  </CListGroupItem>
  <CListGroupItem as="a" href="#">
    <div className="d-flex w-100 justify-content-between">
      <h5 className="mb-1">List group item heading</h5>
      <small className="text-body-secondary">3 days ago</small>
    </div>
    <p className="mb-1">
      Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
    </p>
    <small className="text-body-secondary">Donec id elit non mi porta.</small>
  </CListGroupItem>
</CListGroup>
```

## Checkboxes and radios

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

```jsx preview
<CListGroup>
  <CListGroupItem>
    <CFormCheck label="Cras justo odio" />
  </CListGroupItem>
  <CListGroupItem>
    <CFormCheck label="Dapibus ac facilisis in" defaultChecked />
  </CListGroupItem>
  <CListGroupItem>
    <CFormCheck label="Morbi leo risus" defaultChecked />
  </CListGroupItem>
  <CListGroupItem>
    <CFormCheck label="orta ac consectetur ac" />
  </CListGroupItem>
  <CListGroupItem>
    <CFormCheck label="Vestibulum at eros" />
  </CListGroupItem>
</CListGroup>
```

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

```jsx preview
<CListGroup>
  <CListGroupItem>
    <CFormCheck hitArea="full" label="First checkbox" value="" id="firstCheckboxStretched" />
  </CListGroupItem>
  <CListGroupItem>
    <CFormCheck hitArea="full" label="Second checkbox" value="" id="secondCheckboxStretched" defaultChecked/>
  </CListGroupItem>
  <CListGroupItem>
    <CFormCheck hitArea="full" label="Third checkbox" value="" id="thirdCheckboxStretched"/>
  </CListGroupItem>
</CListGroup>
```

## Customizing

### CSS variables

React list groups use local CSS variables on `.list-group` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

<ScssDocs file="_list-group.scss" capture="list-group-css-vars"/>

#### How to use CSS variables

```jsx
const vars = { 
  '--my-css-var': 10,
  '--my-another-css-var': "red" 
}
return <CListGroup style={vars}>...</CListGroup>
```

### SASS variables

<ScssDocs file="_variables.scss" capture="list-group-variables"/>

## API

### CListGroup

`markdown:CListGroup.api.mdx`

### CListGroupItem

`markdown:CListGroupItem.api.mdx`
