React

List

A component that represents content organized in horizontal rows.

Available since@seed-design/react@0.2.3, @seed-design/css@0.2.3

Installation

npx @seed-design/cli@latest add ui:list

Usage

import { ListHeader } from "seed-design/ui/list-header";
import { List, ListItem } from "seed-design/ui/list";

<VStack>
  <ListHeader as="h2">List Header</ListHeader>
  <List>
    <ListItem title="List Item 1" />
    <ListDivider />
    <ListItem title="List Item 2" />
  </List>
</VStack>

Props

ListHeader

Prop

Type

List

Same as VStackProps.

List Items

Examples

Using ListHeader

ListHeader is positioned outside the List.

Affixes (Prefix/Suffix)

Clickable List Items

You can make the entire list item clickable by using ListButtonItem or ListLinkItem.

If you include clickable elements in prefix or suffix, apply styles like z-index: 1, position: relative, and isolation: isolate so click events work separately from the list item. Crispy React components like ActionButton and ToggleButton do not require additional styling.

inputs in List Items

You can include input elements in list items by using ListSwitchItem, ListCheckItem, or ListRadioItem. In this case, place control elements like Switchmark, Checkmark, or Radiomark in the prefix or suffix area.

Accessibility

List is <ul> by default. When using ListCheckItem and ListRadioItem, you should provide an appropriate role to List.

<List as="fieldset">
  <ListCheckItem
    suffix={<Checkmark size="large" />}
    title="Agree to receive notifications"
    detail="Do you want to receive push notifications?"
  />
  <ListCheckItem
    suffix={<Checkmark size="large" />}
    title="Agree to receive marketing information"
    detail="Do you want to receive marketing information?"
  />
</List>
<List asChild>
  <RadioGroup.Root defaultValue="jjajang" aria-label="Lunch menu"> {/* <div role="radiogroup"> */}
    <ListRadioItem
      suffix={<Radiomark size="large" />}
      value="jjajang"
      title="Jjajang"
    />
    <ListRadioItem
      suffix={<Radiomark size="large" />}
      value="jjamppong"
      title="Jjamppong"
    />
  </RadioGroup.Root>
</List>

Disabled

Variants

Highlighted

With Bottom Sheet

Alignment

You can adjust the alignment of prefix and suffix using the alignItems prop.

Border Radius

You can adjust the radius of list items applied in the active state by setting the itemBorderRadius prop on List. This is useful when the list is contained in a rounded container like a card.

Customization and Composition

Usage

The List and ListHeader components provided in the @seed-design/react package are used with the following structure:

ListHeader
List.Root
└── List.Item
    ├── List.Prefix (optional)
    ├── List.Content
    │   ├── List.Title
    │   └── List.Detail (optional)
    └── List.Suffix (optional)
└── List.Item
    ├── ...
import { ListHeader, List, Icon } from "@seed-design/react";

<ListHeader>
  My Information
</ListHeader>
<List.Root>
  <List.Item>
    <List.Prefix>
      <Icon svg={<IconPersonCircleLine />} />
    </List.Prefix>
    <List.Content>
      <List.Title>My Profile</List.Title>
      <List.Detail>Manage my information displayed to others.</List.Detail>
    </List.Content>
    <List.Suffix>
      <Icon svg={<IconArrowRightLine />} />
    </List.Suffix>
  </List.Item>
  <List.Item>
    {/* ... */}
  </List.Item>
</List.Root>
  • ListHeader: Header role displaying the list title or description
  • List.Root: Container role wrapping all list items
    • List.Item: Individual list item. Defines the clickable area
    • List.Prefix: Starting area where icons, Avatar, Checkmark, etc. can be displayed
    • List.Content: Central area for main content
      • List.Title: Title of the list item
      • List.Detail: Additional description or detailed information
    • List.Suffix: Ending area where icons, Action Button, Toggle Button, etc. can be displayed

Combining with appropriate semantic elements using the asChild prop

Composition

Learn more about the asChild prop.

Using asChild prop in List.Content

This is a pattern that can be used when you want to make the entire list item area a clickable button. In this case, be careful not to use the asChild prop on List.Item. If you put a button in List.Prefix or List.Suffix, invalid HTML is generated with nested button elements.

import { List as SeedList } from "@seed-design/react";

<SeedList.Item>
  <SeedList.Content asChild>
    <button type="button" onClick={() => alert("User clicked")}>
      <SeedList.Title>User</SeedList.Title>
    </button>
  </SeedList.Content>
  <SeedList.Suffix>
    <ActionButton
      size="xsmall"
      variant="brandSolid"
      onClick={() => alert("View clicked")}
    >
      View
    </ActionButton>
  </SeedList.Suffix>
</SeedList.Item>

ListButtonItem and ListLinkItem provided as Snippet help implement this pattern easily.

import { ListButtonItem } from "seed-design/ui/list";

<ListButtonItem
  onClick={() => alert("User clicked")}
  title="User"
  detail="6 items"
  suffix={
    <ActionButton
      size="xsmall"
      variant="brandSolid"
      onClick={() => alert("View clicked")}
    >
      View
    </ActionButton>
  }
/>

Using asChild prop in List.Item

This is a pattern that can be used when you want to make the entire list item area a label, and place Switchmark, Checkmark, or Radiomark in List.Prefix or List.Suffix.

import { List as SeedList } from "@seed-design/react";
import { Checkbox } from "@seed-design/react/primitive";

<SeedList.Item asChild> {/* <label> */}
  <Checkbox.Root defaultChecked>
    <SeedList.Content>
      <SeedList.Title>Agree</SeedList.Title>
    </SeedList.Content>
    <SeedList.Suffix>
      <Checkmark />
    </SeedList.Suffix>
    <Checkbox.HiddenInput />
  </Checkbox.Root>
</SeedList.Item>

ListSwitchItem, ListCheckItem, and ListRadioItem provided as Snippet help implement this pattern easily.

import { ListCheckItem } from "seed-design/ui/list";

<ListCheckItem
  defaultChecked
  title="Agree"
  suffix={<Checkmark size="large" />}
/>

Table of contents