List Component

The List component is a flexible UI primitive for simple lists, icon lists, drawer navigation, dropdown menus, nested submenus, and tree-style structures. Items can render as static content, buttons, or links, with optional leading and trailing content.

Use variant, density, and size for visual tone, href or onClick for actions, and subItems with defaultExpandedIds for submenu-style navigation. Bullets are off by default so lists drop cleanly into drawers, sidebars, and menus.

Import Component From Library

javascript
1import { List } from "@neuctra/ui";

Basic Usage Code

Start with a normal content list. Static rows render as content, while rows with links, clicks, or children become interactive.

jsx
1import { List } from "@neuctra/ui";
2
3function BasicExample() {
4  const items = [
5    { text: "First item" },
6    { text: "Second item" },
7    {
8      text: "Third item",
9      subItems: [
10        { text: "Nested A" },
11        { text: "Nested B" }
12      ]
13    }
14  ];
15
16  return <List items={items} />;
17}

Basic Example

  • First item
  • Second item

Navigation Drawer

Workspace

Drawer friendly navigation

Dropdown Menu List

  • New fileN
  • New folderF
  • BillingPro
  • Security
  • Sign out

List Types And Markers

Inline Navigation
Setup Steps
  • Install dependencies
  • Configure project
  • Run application

Cards And Icon Lists

  • NotificationsUser alerts and product updatesLive
  • SecurityAudit logs, permissions, and sessions

Tree View

  • First item
  • Second item

Item Structure

Each item supports static content, link rows, button rows, separators, metadata, and nested submenus.

tsx
1type ListItemType = {
2  id?: string | number;
3  text?: ReactNode;
4  label?: ReactNode;
5  description?: ReactNode;
6  icon?: ReactNode;
7  leading?: ReactNode;
8  trailing?: ReactNode;
9  badge?: ReactNode;
10  shortcut?: ReactNode;
11
12  href?: string;
13  target?: React.HTMLAttributeAnchorTarget;
14  onClick?: (event, item) => void;
15
16  subItems?: ListItemType[];
17  items?: ListItemType[];
18  active?: boolean;
19  disabled?: boolean;
20  danger?: boolean;
21  separator?: boolean;
22  hidden?: boolean;
23};

List Props

PropTypeDefaultDescription
titleReactNode-Optional heading above the list.
titleIconReactNode-Icon rendered before the title.
descriptionReactNode-Supporting text under the title.
itemsListItemType[]-Main data source for rows and nested rows.
type"unordered" | "ordered" | "inline""unordered"Controls list layout.
variant"default" | "nav" | "menu" | "card" | "ghost""default"Changes row styling for content lists, navs, menus, and cards.
size"sm" | "md" | "lg""md"Controls row text scale.
density"compact" | "normal" | "comfortable""normal"Controls row padding.
nestedMode"always" | "collapse""collapse"Controls whether nested items are always visible or collapsible.
bulletVariant"dot" | "line" | "number" | "none""dot"Custom marker style when showBullets is enabled.
showTreebooleanfalseShows hierarchy connector lines.
showBulletsbooleanfalseShows custom markers when rows have no icon.
showDividersbooleanfalseAdds borders between rows.
interactivebooleantrueEnables clickable row behavior.
fullWidthbooleantrueMakes the root fill available width.
disabledbooleanfalseDisables all list items.
activeItemIdstring | number-Controlled active item id.
defaultActiveItemIdstring | number-Initial active item id for uncontrolled usage.
onActiveChange(id, item) => void-Called when a selectable item is activated.
expandedIdsArray<string | number>-Controlled expanded submenu ids.
defaultExpandedIdsArray<string | number>[]Initial expanded submenu ids for uncontrolled usage.
onExpandedChange(ids) => void-Called when collapsible submenu state changes.
rolestring-Role applied to the ul/ol element.
ariaLabelstring-Accessible label for the list element.
emptyStateReactNode"No items to show."Rendered when items are empty.
linkComponentElementType"a"Custom link component for routers such as Link.
renderItem(params) => ReactNode-Full custom row renderer with active, expanded, toggle, and select helpers.

ListItemType Props

PropTypeDefaultDescription
idstring | number-Stable id for active and expanded state.
textReactNode-Primary row label. Legacy-friendly alias.
labelReactNode-Primary row label alternative.
descriptionReactNode-Secondary text under the label.
iconReactNode-Leading icon.
leadingReactNode-Leading custom content. Falls back to icon.
trailingReactNode-Trailing custom content.
badgeReactNode-Small badge beside the row label.
shortcutReactNode-Keyboard shortcut hint.
hrefstring-Renders the item as a link.
targetHTMLAttributeAnchorTarget-Anchor target, such as _blank.
relstringautoAnchor rel. _blank defaults to noreferrer.
downloadboolean | string-Anchor download attribute.
onClick(event, item) => void-Click handler for the row.
subItemsListItemType[]-Nested children.
itemsListItemType[]-Nested children alias.
expandedboolean-Per-item controlled expanded state.
defaultExpandedboolean-Initial expanded state for the item.
collapsiblebooleantrue in collapse modeControls the submenu chevron behavior.
activebooleanfalseMarks the item active.
disabledbooleanfalseDisables the item.
dangerbooleanfalseApplies destructive styling.
separatorbooleanfalseRenders a divider row.
hiddenbooleanfalseExcludes the item from rendering.
titlestring-Native title attribute.
ariaLabelstring-Accessible label for the row.
rolestring-Role applied to the li element.
className / stylestring / CSSProperties-Per-item wrapper customization.
contentClassName / contentStylestring / CSSProperties-Per-item clickable/content row customization.
iconClassName / iconStylestring / CSSProperties-Per-item icon override, merged with the list's iconClassName/iconStyle.
textClassName / textStylestring / CSSProperties-Per-item label override, merged with the list's textClassName/textStyle.
descriptionClassName / descriptionStylestring / CSSProperties-Per-item description text override.
badgeClassName / badgeStylestring / CSSProperties-Per-item badge override, merged with the list's badgeClassName/badgeStyle.
subListClassName / subListStylestring / CSSProperties-Per-item nested <ul> override, merged with the list's subListClassName/subListStyle.

Styling Hooks

Class PropStyle PropTarget
classNamestyleRoot wrapper.
headerClassNameheaderStyleTitle and description wrapper.
listClassNamelistStyleul/ol element.
itemClassNameitemStyleli wrapper.
itemContentClassNameitemContentStyleClickable row/content wrapper.
titleClassNametitleStyleList heading.
descriptionClassNamedescriptionStyleList heading description.
bulletClassNamebulletStyleCustom bullet marker.
textClassNametextStyleItem label text.
iconClassNameiconStyleTitle and item icons.
badgeClassNamebadgeStyleItem badge.
shortcutClassNameshortcutStyleShortcut kbd element.
trailingClassNametrailingStyleTrailing item content.
subListClassNamesubListStyleNested ul element.
separatorClassNameseparatorStyleSeparator row.
chevronClassName—Expand/collapse chevron icon.
externalIconClassName—External-link icon on href items.
emptyStateClassName—Empty state message container.

Common Mistakes

<List primaryColor="#f00" />

This prop does not exist. Use semantic theme classes or the class/style hooks.

{ text: 'Team', subItems: [...] }

In collapse mode, nested items start collapsed unless you use defaultExpanded, defaultExpandedIds, or nestedMode="always".

<List variant="nav" defaultExpandedIds={["team"]} />

Use stable item ids for active and expanded navigation state.

Pro Tips

  • Use variant="nav" inside drawers and sidebars.
  • Use variant="menu" with density="compact" for dropdown menus.
  • Prefer stable id values when using active or expanded state.
  • Pass a router Link through linkComponent when using client-side navigation.
  • Use renderItem only when class and item props are not enough.

Frequently Asked Questions

How do I install and import the List component?

Install the @neuctra/ui package, then import it with: import { List } from "@neuctra/ui";

What variants and sizes does List support?

List supports variants: default, nav, menu, card, ghost and sizes: sm, md, lg. Use the variant and size props to switch between them, or pass a className to layer on custom Tailwind CSS classes.

Is the List component accessible?

List is built with semantic HTML and standard ARIA attributes, and supports keyboard navigation and focus states out of the box, so it works well with screen readers and keyboard-only users.

Built with React, Tailwind CSS & TypeScript.