Skip to content

List

A Material Design 3 vertical list with leading/trailing slots, headline, supporting text, and interactive items with ripple effects.

Import

ts
import { List, ListItem } from '@akashjs/ui';

Basic Usage

ts
List({
  children: [
    ListItem({ headline: 'Item One' }),
    ListItem({ headline: 'Item Two' }),
    ListItem({ headline: 'Item Three' }),
  ],
})

Dense List

The dense prop reduces vertical padding.

ts
List({
  dense: true,
  children: [
    ListItem({ headline: 'Compact Item One' }),
    ListItem({ headline: 'Compact Item Two' }),
  ],
})

List Items with Supporting Text

Add a secondary line with the supporting prop. Items with supporting text have a taller minimum height (72px vs 56px).

ts
List({
  children: [
    ListItem({
      headline: 'Photos',
      supporting: 'Jan 9, 2024',
    }),
    ListItem({
      headline: 'Documents',
      supporting: '124 files',
    }),
  ],
})

Leading and Trailing Slots

Pass any DOM node to the leading or trailing props.

ts
const icon = document.createElement('span');
icon.textContent = 'F';

const badge = document.createElement('span');
badge.textContent = '3';

ListItem({
  leading: icon,
  headline: 'Inbox',
  supporting: '3 new messages',
  trailing: badge,
})

Clickable Items

Add an onClick handler to make items interactive. Clickable items gain hover highlighting and a ripple effect.

ts
List({
  children: [
    ListItem({
      headline: 'Settings',
      onClick: () => navigate('/settings'),
    }),
    ListItem({
      headline: 'Profile',
      onClick: () => navigate('/profile'),
    }),
  ],
})

Disabled Items

Disabled items render at 38% opacity with no interactions.

ts
ListItem({
  headline: 'Unavailable',
  disabled: true,
})

Props

List

NameTypeDefaultDescription
densebooleanfalseReduces padding for a more compact list
childrenAkashNode--ListItem elements

ListItem

NameTypeDefaultDescription
headlinestring(required)Primary text
supportingstring--Secondary text below the headline
leadingAkashNode--Content placed before the headline (icon, avatar, etc.)
trailingAkashNode--Content placed after the headline (badge, icon, etc.)
onClick(e: MouseEvent) => void--Click handler (enables hover and ripple)
disabledbooleanfalseDisables hover, click, and ripple

Released under the MIT License.