Skip to content

ListGroup ​

A flexible and interactive component for displaying grouped lists with support for icons, badges, links, buttons, active/disabled states, striped and flush variants, and horizontal layouts. Useful for navigation menus, settings, dashboards, and any grouped content.


Import ​

tsx
import { ListGroup } from '@odyssee/components';
// Helpers: ListGroup.Link, ListGroup.Button, ListGroup.Flush, ListGroup.Horizontal

Examples ​

Basic List Group ​

Code Éditable
Résultat

List Group with Icons ​

Code Éditable
Résultat

List Group with Badges ​

Code Éditable
Résultat

Code Éditable
Résultat

List Group as Buttons ​

Code Éditable
Résultat

Striped List Group ​

Code Éditable
Résultat

Flush Variant (No Borders) ​

Code Éditable
Résultat

Horizontal Variant (Responsive) ​

Code Éditable
Résultat

Active and Disabled States ​

Code Éditable
Résultat

Props Table ​

ListGroup Props ​

PropTypeDefaultDescription
items(string | ListGroup.Item)[]— (required)Array of items (strings or objects with content, icon, badge, etc.).
variant"default" | "flush" | "horizontal""default"Visual style of the group: bordered, flush (no borders), or horizontal layout.
as"li" | "button" | "a""li"Render items as <li>, <button>, or <a>.
stripedbooleanfalseAlternating background for items (default variant only).
noGuttersbooleanfalseRemove horizontal padding from items.
size"sm" | "md" | "lg""md"Size of the items.
activeIndexnumber | Signal<number>—Index of the active item (overrides per-item active).
onItemClick(item: ListGroup.Item | string, index: number) => void—Callback when an item is clicked (button or li mode).
classNamestring—Additional CSS classes for the container.
idstringauto-genHTML id attribute.
stylestring—Inline styles.

ListGroup.Item ​

FieldTypeDescription
idstringOptional unique identifier.
contentstring | HTMLElementThe content of the item.
iconHTMLElement | stringOptional icon to display before the content.
badgestring | numberOptional badge (number or label) to display.
badgeColorColorBadge color (primary, secondary, success, etc.).
hrefstringLink URL (for link variant).
activebooleanMark item as active.
disabledbooleanMark item as disabled.
onClick(event: Event) => voidItem-specific click handler.

Helper Components ​

  • ListGroup.Link: Renders items as <a> links.
  • ListGroup.Button: Renders items as <button>.
  • ListGroup.Flush: Flush variant (no borders, uses dividers).
  • ListGroup.Horizontal: Responsive horizontal layout.

Implementation Notes ​

  • Variants:
    • "default": Bordered, stacked list (with optional stripes).
    • "flush": No borders, uses dividers.
    • "horizontal": Responsive row layout on larger screens.
  • Rendering:
    • Use as="a" for navigation, as="button" for actions, or default for static lists.
  • Icons & Badges:
    • Each item can have an icon and/or a badge (with color).
  • Active/Disabled:
    • Items can be marked as active or disabled (visually and for interaction).
  • Helpers:
    • Use helper components for common variants and less boilerplate.
  • Composition:
    • Items can be strings (simple) or objects (for advanced formatting).

Accessibility ​

  • Uses semantic <ul>, <li>, <a>, and <button> elements as appropriate.
  • Disabled items are not focusable or clickable.
  • Active items are visually distinct.
  • Badges and icons are decorative; ensure the main content is descriptive.
  • For navigation, add ARIA roles as needed in your context.

Best Practices ​

  • Use for navigation menus, settings, dashboards, or grouped actions.
  • Prefer semantic and descriptive content for accessibility.
  • Use icons and badges to enhance clarity and context.
  • Use the horizontal variant for tabs or responsive navigation.
  • Combine with cards, sidebars, or sections for richer UIs.


Released under the MIT License.