# List
URL: /react/components/list
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/list.mdx
A component that represents content organized in horizontal rows.
사용 가능 버전: @seed-design/react@0.2.3, @seed-design/css@0.2.3
## Preview
```tsx
import { List, ListDivider, ListItem } from "seed-design/ui/list";
import { ListHeader } from "seed-design/ui/list-header";
import {
IconILowercaseSerifCircleLine,
IconPersonCircleLine,
} from "@karrotmarket/react-monochrome-icon";
import { Icon, VStack } from "@seed-design/react";
export default function ListPreview() {
return (
List header} />}
title="List item with icon"
detail="Description with extra info"
suffix={} />}
/>
);
}
```
## Installation
- npm: npx @seed-design/cli@latest add ui:list
- pnpm: pnpm dlx @seed-design/cli@latest add ui:list
- yarn: yarn dlx @seed-design/cli@latest add ui:list
- bun: bun x @seed-design/cli@latest add ui:list
## Usage
```tsx
import { ListHeader } from "seed-design/ui/list-header";
import { List, ListItem } from "seed-design/ui/list";
List Header
```
## Props
### `ListHeader`
### `List`
Same as [`VStackProps`](/react/components/layout/v-stack#props).
### List Items
Same as [`DividerProps`](/react/components/divider#props), but renders as `
` by default. If you change `List` to use `fieldset` or similar, please replace `ListDivider` with an appropriate tag as well.
## Examples
### Using `ListHeader`
`ListHeader` is positioned outside the `List`.
```tsx
import { List, ListButtonItem } from "seed-design/ui/list";
import { ListHeader } from "seed-design/ui/list-header";
import { ActionButton } from "seed-design/ui/action-button";
import {
IconChevronRightLine,
IconLockLine,
IconPersonCircleLine,
IconQuestionmarkCircleFill,
} from "@karrotmarket/react-monochrome-icon";
import { Divider, Icon, PrefixIcon, VStack } from "@seed-design/react";
export default function () {
return (
variant="mediumWeak"
} />}
suffix={} size="18px" />}
/>
} />}
suffix={} size="x4_5" />}
/>
variant="boldSolid"
} />}
suffix={} size="18px" />}
/>
} />}
suffix={} size="x4_5" />}
/>
List Header with Action Button
} />
도움말
} />}
suffix={} size="18px" />}
/>
} />}
suffix={} size="x4_5" />}
/>
);
}
```
### Affixes (Prefix/Suffix)
```tsx
import {
IconArrowUpBracketDownFill,
IconILowercaseSerifCircleLine,
} from "@karrotmarket/react-monochrome-icon";
import { Icon } from "@seed-design/react";
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import { Avatar } from "seed-design/ui/avatar";
import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
import { List, ListDivider, ListItem } from "seed-design/ui/list";
import { ToggleButton } from "seed-design/ui/toggle-button";
export default function ListAffixes() {
const [isToggleButtonPressed, setIsToggleButtonPressed] = useState(false);
return (
}
/>
}
title="Prefix에 Avatar 넣기"
detail="Amet elit ullamco magna."
/>
} />}
/>
액션 버튼
}
/>
} />
}
/>
{isToggleButtonPressed ? "선택됨" : "토글 버튼"}
}
/>
);
}
```
### 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.
```tsx
import {
IconArrowUpRightLine,
IconCheckmarkFill,
IconChevronRightLine,
IconPenHorizlineFill,
IconPlusFill,
IconSquare2StackedFill,
} from "@karrotmarket/react-monochrome-icon";
import { PrefixIcon, Icon, Box } from "@seed-design/react";
import { useCallback, useState } from "react";
import { List, ListDivider, ListItem, ListButtonItem, ListLinkItem } from "seed-design/ui/list";
import { ActionButton } from "seed-design/ui/action-button";
import { ToggleButton } from "seed-design/ui/toggle-button";
const href = "https://www.daangn.com";
export default function ListClickable() {
const [isSubscribed, setIsSubscribed] = useState(false);
const [isCopied, setIsCopied] = useState(false);
const onCopyClick = useCallback(() => {
navigator.clipboard.writeText(href);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 2000);
}, []);
return (
alert("편집 클릭됨")}
>
} />
편집
}
/>
alert("리스트 아이템 클릭됨")}
suffix={
<>
: } />
{isSubscribed ? "모아보는 중" : "모아보기"}
} />
>
}
/>
alert("리스트 아이템 클릭됨")}
suffix={
<>
} />
>
}
/>
: } />
{isCopied ? "복사됨" : "URL 복사"}
} />
>
}
href={href}
target="_blank"
rel="noreferrer"
/>
);
}
```
### `input`s 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](/react/components/switch#using-switchmark), [Checkmark](/react/components/checkbox#using-checkmark), or [Radiomark](/react/components/radio-group#using-radiomark) in the `prefix` or `suffix` area.
```tsx
import { IconTrashcanLine } from "@karrotmarket/react-monochrome-icon";
import { IconSparkle2 } from "@karrotmarket/react-multicolor-icon";
import { Icon } from "@seed-design/react";
import { List, ListDivider, ListSwitchItem } from "seed-design/ui/list";
import { Switchmark } from "seed-design/ui/switch";
export default function ListSwitch() {
return (
} />}
suffix={}
/>
} />}
suffix={}
defaultChecked
/>
);
}
```
```tsx
import { Badge, HStack } from "@seed-design/react";
import { List, ListDivider, ListCheckItem } from "seed-design/ui/list";
import { Checkmark } from "seed-design/ui/checkbox";
export default function ListCheckbox() {
return (
알림 수신 동의권장
}
detail="푸시 알림을 받으시겠습니까?"
suffix={}
defaultChecked
/>
}
title="마케팅 정보 수신 동의"
detail="마케팅 정보를 받으시겠습니까?"
defaultChecked
/>
}
title="Ghost Variant"
/>
);
}
```
```tsx
import { RadioGroup } from "@seed-design/react/primitive";
import { List, ListDivider, ListRadioItem } from "seed-design/ui/list";
import { Radiomark } from "seed-design/ui/radio-group";
export default function ListRadio() {
return (
}
/>
}
value="option2"
title="옵션 2"
detail="두 번째 선택지"
/>
}
value="option3"
title="옵션 3"
detail="세 번째 선택지"
/>
);
}
```
### Accessibility
`List` is `
` by default. When using `ListCheckItem` and `ListRadioItem`, you should provide an appropriate role to `List`.
```tsx
{/* [!code highlight] */}
}
title="Agree to receive notifications"
detail="Do you want to receive push notifications?"
/>
}
title="Agree to receive marketing information"
detail="Do you want to receive marketing information?"
/>
```
```tsx
{/* [!code highlight] */}
{/*
*/}
}
value="jjajang"
title="Jjajang"
/>
}
value="jjamppong"
title="Jjamppong"
/>
```
### Disabled
```tsx
import {
IconChevronRightLine,
IconPersonCircleLine,
IconSlashCircleLine,
} from "@karrotmarket/react-monochrome-icon";
import { Divider, Icon, VStack } from "@seed-design/react";
import { RadioGroup } from "@seed-design/react/primitive";
import { List, ListButtonItem, ListCheckItem, ListRadioItem } from "seed-design/ui/list";
import { Checkmark } from "seed-design/ui/checkbox";
import { Radiomark } from "seed-design/ui/radio-group";
export default function ListDisabled() {
return (
} />}
title="활성화된 ListButtonItem"
detail="Cupidatat et pariatur amet."
suffix={} />}
/>
} />}
title="활성화된 ListCheckItem"
suffix={}
/>
} />}
title="활성화된 ListRadioItem"
suffix={}
value="foo"
/>
} />}
title="비활성화된 ListButtonItem"
detail="Cupidatat et pariatur amet."
suffix={} />}
/>
} />}
title="비활성화된 ListCheckItem"
suffix={}
/>
} />}
title="비활성화된 ListRadioItem"
suffix={}
value="foo"
/>
);
}
```
### Variants
#### Highlighted
```tsx
import { IconPersonCircleLine } from "@karrotmarket/react-monochrome-icon";
import { Box, Icon, VStack } from "@seed-design/react";
import { useState } from "react";
import { List, ListDivider, ListItem, ListButtonItem } from "seed-design/ui/list";
import { Switch } from "seed-design/ui/switch";
export default function ListHighlighted() {
const [highlighted, setHighlighted] = useState(true);
return (
} />}
title="버튼"
detail="Enim aute duis magna mollit aute sit aliquip duis ut tempor sunt."
onClick={() => {}}
/>
} />}
title="하이라이트된 버튼"
detail="Enim aute duis magna mollit aute sit aliquip duis ut tempor sunt."
onClick={() => {}}
/>
} />}
title="하이라이트 및 비활성화된 버튼"
detail="Enim aute duis magna mollit aute sit aliquip duis ut tempor sunt."
onClick={() => {}}
/>
} />}
title="하이라이트"
highlighted={highlighted}
/>
);
}
```
### With Bottom Sheet
```tsx
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
import { ActionButton } from "seed-design/ui/action-button";
import { Checkmark } from "seed-design/ui/checkbox";
import { List, ListCheckItem } from "seed-design/ui/list";
import { PrefixIcon, VStack } from "@seed-design/react";
import { useState } from "react";
import { IconArrowClockwiseCircularFill } from "@karrotmarket/react-monochrome-icon";
const TYPES = ["버스", "지하철", "택시", "자전거", "도보"] as const;
export default function ListBottomSheet() {
const [isOpen, setIsOpen] = useState(false);
const [selectedTypes, setSelectedTypes] = useState<(typeof TYPES)[number][]>([]);
return (
BottomSheet 열기
);
}
```
### Alignment
You can adjust the alignment of `prefix` and `suffix` using the `alignItems` prop.
```tsx
import { List, ListItem } from "seed-design/ui/list";
import { HStack } from "@seed-design/react";
import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
import { Avatar } from "seed-design/ui/avatar";
export default function ListAlignment() {
return (
} />}
title="Prefix에 Avatar 넣기. Veniam elit velit esse ea incididunt sunt sit aute."
detail="Et proident sit ullamco ut voluptate. Voluptate eiusmod occaecat adipisicing quis qui esse."
/>
} />}
title="Prefix에 Avatar 넣고 상단으로 정렬하기. Veniam elit velit esse ea incididunt sunt sit aute."
detail="일반적으로 `title`이 길어질 때 `alignItems`를 `flex-start`로 설정합니다."
/>
);
}
```
### 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.
```tsx
import { List, ListCheckItem, ListRadioItem } from "seed-design/ui/list";
import { ListHeader } from "seed-design/ui/list-header";
import { Checkmark } from "seed-design/ui/checkbox";
import { Radiomark } from "seed-design/ui/radio-group";
import { HStack, VStack } from "@seed-design/react";
import { RadioGroup } from "@seed-design/react/primitive";
export default function ListBorderRadius() {
return (
카드 borderRadius: r3_5}
/>
}
/>
카드 borderRadius: 22px}
/>
}
/>
);
}
```
## 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
├── ...
```
```tsx
import { ListHeader, List, Icon } from "@seed-design/react";
My Information
} />
My ProfileManage my information displayed to others.} />
{/* ... */}
```
- `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](/react/components/avatar), [Checkmark](/react/components/checkbox#using-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](/react/components/action-button), [Toggle Button](/react/components/toggle-button), etc. can be displayed
### Combining with appropriate semantic elements using the `asChild` prop
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.
```tsx
import { List as SeedList } from "@seed-design/react";
{/* [!code highlight] */}
{/* [!code highlight] */}
{/* [!code highlight] */}
alert("View clicked")}
>
View
```
`ListButtonItem` and `ListLinkItem` provided as [Snippet](/react/components/concepts/snippet) help implement this pattern easily.
```tsx
import { ListButtonItem } from "seed-design/ui/list";
alert("User clicked")}
title="User"
detail="6 items"
suffix={
alert("View clicked")}
>
View
}
/>
```
#### 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](/react/components/switch#using-switchmark), [Checkmark](/react/components/checkbox#using-checkmark), or [Radiomark](/react/components/radio-group#using-radiomark) in `List.Prefix` or `List.Suffix`.
```tsx
import { List as SeedList } from "@seed-design/react";
import { Checkbox } from "@seed-design/react/primitive";
{/* [!code highlight] */}
{/*
```
`ListSwitchItem`, `ListCheckItem`, and `ListRadioItem` provided as [Snippet](/react/components/concepts/snippet) help implement this pattern easily.
```tsx
import { ListCheckItem } from "seed-design/ui/list";
}
/>
```