Angular List Group Component

List Group

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

Available in Other JavaScript Frameworks

CoreUI Angular List Group Component is also available for Bootstrap, React, and Vue. Explore framework-specific implementations below:

Examples

Basic

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.

import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group',
  templateUrl: './list-group.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupComponent {}
<ul cListGroup>
  <li cListGroupItem>Cras justo odio</li>
  <li cListGroupItem>Dapibus ac facilisis in</li>
  <li cListGroupItem>Morbi leo risus</li>
  <li cListGroupItem>Porta ac consectetur ac</li>
  <li cListGroupItem>Vestibulum at eros</li>
</ul>

Active item

Add active boolean property for cListGroupItem to show the current active selection.

import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-active-item',
  templateUrl: './list-group-active-item.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupActiveItemComponent {}
<ul cListGroup>
  <li [active]="true" cListGroupItem>Cras justo odio</li>
  <li cListGroupItem>Dapibus ac facilisis in</li>
  <li cListGroupItem>Morbi leo risus</li>
  <li cListGroupItem>Porta ac consectetur ac</li>
  <li cListGroupItem>Vestibulum at eros</li>
</ul>

Disabled item

Add disabled attribute property for cListGroupItem to make it appear disabled.

import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-disabled-item',
  templateUrl: './list-group-disabled-item.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupDisabledItemComponent {}
<ul cListGroup>
  <li cListGroupItem disabled>Cras justo odio</li>
  <li cListGroupItem>Dapibus ac facilisis in</li>
  <li cListGroupItem [disabled]="true">Morbi leo risus</li>
  <li cListGroupItem [disabled]="false">Porta ac consectetur ac</li>
  <li cListGroupItem>Vestibulum at eros</li>
</ul>

Use a or button to create actionable list group items with hover, disabled, and active states. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like li or div) don’t provide a click or tap affordance.

import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-links-buttons',
  templateUrl: './list-group-links-buttons.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective, RouterLink]
})
export class ListGroupLinksButtonsComponent {}
<div cListGroup>
  <a [routerLink] cListGroupItem [active]="true">Cras justo odio</a>
  <a [routerLink] cListGroupItem>Dapibus ac facilisis in</a>
  <a [routerLink] cListGroupItem>Morbi leo risus</a>
  <a [routerLink] cListGroupItem>Porta ac consectetur ac</a>
  <a [routerLink] cListGroupItem [disabled]="true">Vestibulum at eros</a>
</div>
import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-links-buttons-2',
  templateUrl: './list-group-links-buttons-2.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupLinksButtons2Component {}
<div cListGroup>
  <button cListGroupItem [active]="true">Cras justo odio</button>
  <button cListGroupItem>Dapibus ac facilisis in</button>
  <button cListGroupItem>Morbi leo risus</button>
  <button cListGroupItem>Porta ac consectetur ac</button>
  <button cListGroupItem disabled>Vestibulum at eros</button>
</div>

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

import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-flush',
  templateUrl: './list-group-flush.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupFlushComponent {}
<ul cListGroup flush>
  <li cListGroupItem>Cras justo odio</li>
  <li cListGroupItem>Dapibus ac facilisis in</li>
  <li cListGroupItem>Morbi leo risus</li>
  <li cListGroupItem>Porta ac consectetur ac</li>
  <li cListGroupItem>Vestibulum at eros</li>
</ul>

Horizontal

Add horizontal prop to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant with 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.

import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-horizontal',
  templateUrl: './list-group-horizontal.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupHorizontalComponent {
  breakpoints = [true, 'sm', 'md', 'lg', 'xl', 'xxl'];
}
@for (breakpoint of breakpoints; track i; let i = $index) {
  <ul
    [horizontal]="breakpoint"
    cListGroup
    class="mb-2">
    <li cListGroupItem>Cras justo odio</li>
    <li cListGroupItem>Dapibus ac facilisis in</li>
    <li cListGroupItem>Morbi leo risus</li>
  </ul>

}

Contextual classes

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

import { Component } from '@angular/core';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-contextual-classes',
  templateUrl: './list-group-contextual-classes.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective]
})
export class ListGroupContextualClassesComponent {
  colors = ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'];
}
<ul cListGroup>
  @for (color of colors; track color) {
    <li [color]="color" cListGroupItem>
      A simple {{ color }} list group item
    </li>
  }
</ul>

Contextual classes also work with a or button. 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.

import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-colors-for-links-buttons',
  templateUrl: './list-group-colors-for-links-buttons.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective, RouterLink]
})
export class ListGroupColorsForLinksButtonsComponent {
  colors = ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'];
}
<div cListGroup>
  @for (color of colors; track color) {
    <a [color]="color"
       cListGroupItem
       [routerLink]>
      A simple {{ color }} list group item
    </a>
  }
</div>
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.

import { Component } from '@angular/core';
import { BadgeComponent, ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-with-badges',
  templateUrl: './list-group-with-badges.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective, BadgeComponent]
})
export class ListGroupWithBadgesComponent {}
<div cListGroup>
  <button cListGroupItem class="d-flex justify-content-between align-items-center">
    Cras justo odio
    <c-badge color="primary" shape="rounded-pill">14</c-badge>
  </button>
  <button cListGroupItem class="d-flex justify-content-between align-items-center">
    Dapibus ac facilisis in
    <c-badge color="primary" shape="rounded-pill">2</c-badge>
  </button>
  <button cListGroupItem class="d-flex justify-content-between align-items-center">
    Morbi leo risus
    <c-badge color="primary" shape="rounded-pill">1</c-badge>
  </button>
  <button cListGroupItem class="d-flex justify-content-between align-items-center">
    Porta ac consectetur
    <c-badge color="primary" shape="rounded-pill">1</c-badge>
  </button>
  <button cListGroupItem class="d-flex justify-content-between align-items-center" disabled>
    Vestibulum at eros
    <c-badge color="secondary" shape="rounded-pill">42</c-badge>
  </button>
</div>

Custom content

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

import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { ListGroupDirective, ListGroupItemDirective } from '@coreui/angular';

@Component({
  selector: 'docs-list-group-custom-content',
  templateUrl: './list-group-custom-content.component.html',
  imports: [ListGroupDirective, ListGroupItemDirective, RouterLink]
})
export class ListGroupCustomContentComponent {}
<div cListGroup>
  <a [active]="true" [routerLink] cListGroupItem>
    <div class="d-flex w-100 justify-content-between">
      <h5 class="mb-1">List group item heading</h5>
      <small>3 days ago</small>
    </div>
    <p class="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>
  </a>
  <a [routerLink] cListGroupItem>
    <div class="d-flex w-100 justify-content-between">
      <h5 class="mb-1">List group item heading</h5>
      <small class="text-medium-emphasis">3 days ago</small>
    </div>
    <p class="mb-1">
      Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget
      risus varius blandit.
    </p>
    <small class="text-medium-emphasis">Donec id elit non mi porta.</small>
  </a>
  <a [routerLink] cListGroupItem>
    <div class="d-flex w-100 justify-content-between">
      <h5 class="mb-1">List group item heading</h5>
      <small class="text-medium-emphasis">3 days ago</small>
    </div>
    <p class="mb-1">
      Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget
      risus varius blandit.
    </p>
    <small class="text-medium-emphasis">Donec id elit non mi porta.</small>
  </a>
</div>

Checkboxes and radios

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

import { Component, inject } from '@angular/core';
import { ReactiveFormsModule, UntypedFormBuilder } from '@angular/forms';
import {
  ButtonDirective,
  FormCheckComponent,
  FormCheckInputDirective,
  FormCheckLabelDirective,
  FormDirective,
  ListGroupDirective,
  ListGroupItemDirective
} from '@coreui/angular';

@Component({
  selector: 'docs-list-group-checkboxes-radios',
  templateUrl: './list-group-checkboxes-radios.component.html',
  imports: [
    ReactiveFormsModule,
    FormDirective,
    ListGroupDirective,
    ListGroupItemDirective,
    FormCheckComponent,
    FormCheckInputDirective,
    FormCheckLabelDirective,
    ButtonDirective
  ]
})
export class ListGroupCheckboxesRadiosComponent {
  readonly formBuilder = inject(UntypedFormBuilder);

  checkBoxes = this.formBuilder.group({
    one: false,
    two: false,
    three: true,
    four: true,
    five: { value: false, disabled: true }
  });

  setValue(controlName: string) {
    const prevValue = this.checkBoxes.get(controlName)?.value;
    const value = this.checkBoxes.getRawValue();
    value[controlName] = !prevValue;
    this.checkBoxes.setValue(value);
  }

  logValue() {
    console.log(this.checkBoxes.value);
    this.checkBoxes.reset();
  }
}
<form [formGroup]="checkBoxes" (ngSubmit)="logValue()" cForm>
  <ul [flush]="true" cListGroup>
    <button (click)="setValue('one')" cListGroupItem type="button">
      <c-form-check>
        <input cFormCheckInput formControlName="one" type="checkbox"/>
        <label cFormCheckLabel>Cras justo odio</label>
      </c-form-check>
    </button>
    <label cListGroupItem style="cursor: pointer;">
      <c-form-check>
        <input cFormCheckInput formControlName="two" type="checkbox"/>
        Dapibus ac facilisis in
      </c-form-check>
    </label>
    <li cListGroupItem>
      <c-form-check>
        <input cFormCheckInput formControlName="three" type="checkbox"/>
        <label cFormCheckLabel>Morbi leo risus</label>
      </c-form-check>
    </li>
    <li cListGroupItem>
      <c-form-check>
        <input cFormCheckInput formControlName="four" type="checkbox"/>
        <label cFormCheckLabel>Orta ac consectetur ac</label>
      </c-form-check>
    </li>
    <li cListGroupItem>
      <c-form-check>
        <input cFormCheckInput formControlName="five" type="checkbox"/>
        <label cFormCheckLabel>Vestibulum at eros</label>
      </c-form-check>
    </li>
  </ul>
  <button cButton class="mt-3" type="submit">Submit</button>
</form>

API reference

ListGroup Module

import { ListGroupModule } from '@coreui/angular';

@NgModule({
    imports: [ListGroupModule,]
})
export class AppModule() { }

cListGroup

directive

jsx
import { ListGroupDirective } from '@coreui/angular'
PropertyDefaultType
flushfalseboolean

Remove some borders and rounded corners to render list group items edge-to-edge in a parent component (e.g., <CCard>).

horizontal-string, boolean

Specify horizontal layout type.

cListGroupItem

directive

jsx
import { ListGroupItemDirective } from '@coreui/angular'
PropertyDefaultType
activefalseboolean

Toggle the active state for the component.

color-string

Sets the color context of the component to one of CoreUI’s themed colors.

disabledfalseboolean

Set disabled attr for the host element

tabindexundefinednumber

The tabindex attribute specifies the tab order of an element (when the "tab" button is used for navigating).