# List URL: /lynx/components/list Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/list.mdx A component that represents content composed of horizontal rows. 사용 가능 버전: @seed-design/lynx-react@0.7.0, @seed-design/lynx-css@0.11.0 ## Preview ```tsx import "./styles"; import IconILowercaseSerifCircleLine from "@karrotmarket/lynx-monochrome-icon/IconILowercaseSerifCircleLine"; import IconPersonCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPersonCircleLine"; import { PrefixIcon, SuffixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { ListHeader } from "@/components/ui/list-header"; import { List, ListDivider, ListItem } from "@/components/ui/list"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( 리스트 헤더 } />} title="아이콘이 있는 리스트 아이템" detail="부가 정보가 포함된 설명" 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 "@/components/ui/list-header"; import { List, ListDivider, ListItem } from "@/components/ui/list"; List Header ``` ## Props ### `ListHeader` ### `List` ### List Items Lynx has no basic element corresponding to HTML anchor. Link navigation is handled by calling the app router from `ListButtonItem`'s `bindtap`. ## Examples ### Using `ListHeader` `ListHeader` is placed outside `List`. Lynx `ListHeader` renders ``, so actions are placed as siblings of the Header. ```tsx import "./styles"; import IconChevronRightLine from "@karrotmarket/lynx-monochrome-icon/IconChevronRightLine"; import IconLockLine from "@karrotmarket/lynx-monochrome-icon/IconLockLine"; import IconPersonCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPersonCircleLine"; import IconQuestionmarkCircleFill from "@karrotmarket/lynx-monochrome-icon/IconQuestionmarkCircleFill"; import { ActionButton, PrefixIcon, SuffixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListButtonItem, ListDivider } from "@/components/ui/list"; import { ListHeader } from "@/components/ui/list-header"; function AccountList() { return ( } />} suffix={} />} /> } />} suffix={} />} /> ); } export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( variant="mediumWeak" variant="boldSolid" List Header with Action Button } /> 도움말 ); } ``` ### Affixes (Prefix/Suffix) ```tsx import "./styles"; import IconArrowUpBracketDownFill from "@karrotmarket/lynx-monochrome-icon/IconArrowUpBracketDownFill"; import IconILowercaseSerifCircleLine from "@karrotmarket/lynx-monochrome-icon/IconILowercaseSerifCircleLine"; import { useState } from "@lynx-js/react"; import { ActionButton, Icon, PrefixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListDivider, ListItem } from "@/components/ui/list"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [pressed, setPressed] = useState(false); return ( A } title="Prefix에 Avatar 넣기" detail="Amet elit ullamco magna." /> } />} /> 액션 버튼 } /> } /> } /> { "background only"; setPressed((value) => !value); }} > {pressed ? "선택됨" : "토글 버튼"} } /> ); } ``` ### Clickable List Items Using `ListButtonItem` allows tapping the entire list item. Since Lynx has no `ListLinkItem`, screen navigation is handled by calling the app router in `bindtap`. ```tsx import "./styles"; import IconArrowUpRightLine from "@karrotmarket/lynx-monochrome-icon/IconArrowUpRightLine"; import IconCheckmarkFill from "@karrotmarket/lynx-monochrome-icon/IconCheckmarkFill"; import IconChevronRightLine from "@karrotmarket/lynx-monochrome-icon/IconChevronRightLine"; import IconPenHorizlineFill from "@karrotmarket/lynx-monochrome-icon/IconPenHorizlineFill"; import IconPlusFill from "@karrotmarket/lynx-monochrome-icon/IconPlusFill"; import IconSquare2StackedFill from "@karrotmarket/lynx-monochrome-icon/IconSquare2StackedFill"; import { useState } from "@lynx-js/react"; import { ActionButton, PrefixIcon, SuffixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListButtonItem, ListDivider, ListItem } from "@/components/ui/list"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [status, setStatus] = useState("아직 탭하지 않았어요"); const [subscribed, setSubscribed] = useState(false); const [copied, setCopied] = useState(false); return ( { "background only"; setStatus("편집 클릭됨"); }} > } /> 편집 } /> { "background only"; setStatus("리스트 아이템 클릭됨"); }} suffix={ {}}> { "background only"; setSubscribed((value) => !value); setStatus("모아보기 상태 변경됨"); }} > : } /> {subscribed ? "모아보는 중" : "모아보기"} } /> } /> { "background only"; setStatus("리스트 아이템 클릭됨"); }} suffix={ { "background only"; setStatus("커스텀 버튼 클릭됨"); }} > 커스텀 버튼 } /> } /> { "background only"; setStatus("링크 이동 요청됨"); }} suffix={ {}}> { "background only"; setCopied(true); setStatus("URL 복사됨"); }} > : } /> {copied ? "복사됨" : "URL 복사"} } /> } /> {status} ); } ``` ### `input`s in List Items Using `ListSwitchItem`, `ListCheckItem`, `ListRadioItem` allows tapping the entire item to change the value. The snippet renders each control as the default suffix. You can hide the default control by passing `suffix={null}`. ```tsx import "./styles"; import IconTrashcanLine from "@karrotmarket/lynx-monochrome-icon/IconTrashcanLine"; import { PrefixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListDivider, ListSwitchItem } from "@/components/ui/list"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } />} /> ); } ``` ```tsx import "./styles"; import IconCheckmarkFatFill from "@karrotmarket/lynx-monochrome-icon/IconCheckmarkFatFill"; import { Badge, Checkbox, HStack, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListCheckItem, ListDivider } from "@/components/ui/list"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( 알림 수신 동의 권장 } detail="푸시 알림을 받으시겠습니까?" defaultChecked /> } /> } suffix={null} defaultChecked /> } checked={} /> } suffix={null} title="Ghost Variant" /> ); } ``` ```tsx import "./styles"; import { useSeedClassName } from "@seed-design/lynx-react"; import { List, ListDivider, ListRadioItem } from "@/components/ui/list"; import { RadioGroup, Radiomark } from "@/components/ui/radio-group"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } /> } suffix={null} /> } suffix={null} /> ); } ``` ### Accessibility `ListButtonItem` provides button role and string `title`-based accessibility name by default. Selection items pass the current selection status via `accessibility-value`. `ListRadioItem` must be used inside `RadioGroup.Root` and you must specify the group's accessibility name. ```tsx import { List, ListRadioItem } from "@/components/ui/list"; import { RadioGroup } from "@/components/ui/radio-group"; ``` ### Disabled ```tsx import "./styles"; import IconChevronRightLine from "@karrotmarket/lynx-monochrome-icon/IconChevronRightLine"; import IconPersonCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPersonCircleLine"; import IconSlashCircleLine from "@karrotmarket/lynx-monochrome-icon/IconSlashCircleLine"; import { PrefixIcon, SuffixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListButtonItem, ListCheckItem, ListRadioItem } from "@/components/ui/list"; import { RadioGroup } from "@/components/ui/radio-group"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } />} title="활성화된 ListButtonItem" detail="Cupidatat et pariatur amet." suffix={} />} /> } />} title="활성화된 ListCheckItem" /> } />} title="활성화된 ListRadioItem" value="enabled" /> } />} title="비활성화된 ListButtonItem" detail="Cupidatat et pariatur amet." suffix={} />} /> } />} title="비활성화된 ListCheckItem" /> } />} title="비활성화된 ListRadioItem" value="disabled" /> ); } ``` ### Variants #### Highlighted ```tsx import "./styles"; import IconPersonCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPersonCircleLine"; import { useState } from "@lynx-js/react"; import { PrefixIcon, useSeedClassName } from "@seed-design/lynx-react"; import { List, ListButtonItem, ListDivider, ListItem } from "@/components/ui/list"; import { Switch } from "@/components/ui/switch"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [highlighted, setHighlighted] = useState(true); return ( } />} title="버튼" detail="Enim aute duis magna mollit aute sit aliquip duis ut tempor sunt." /> } />} title="하이라이트된 버튼" detail="Enim aute duis magna mollit aute sit aliquip duis ut tempor sunt." /> } />} title="하이라이트 및 비활성화된 버튼" detail="Enim aute duis magna mollit aute sit aliquip duis ut tempor sunt." /> } />} title="하이라이트" highlighted={highlighted} /> highlight ); } ``` ### With Bottom Sheet ```tsx import "./styles"; import IconArrowClockwiseCircularFill from "@karrotmarket/lynx-monochrome-icon/IconArrowClockwiseCircularFill"; import { useRef, useState } from "@lynx-js/react"; import { ActionButton, type BottomSheetRootRef, PrefixIcon, useSeedClassName, } from "@seed-design/lynx-react"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { List, ListCheckItem } from "@/components/ui/list"; const TYPES = ["버스", "지하철", "택시", "자전거", "도보"] as const; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const sheetRef = useRef(null); const [selectedTypes, setSelectedTypes] = useState<(typeof TYPES)[number][]>([]); return ( BottomSheet 열기 {TYPES.map((type) => ( { setSelectedTypes((previous) => previous.includes(type) ? previous.filter((item) => item !== type) : [...previous, type], ); }} /> ))} { "background only"; sheetRef.current?.close(); }} > 경로 찾기 { "background only"; setSelectedTypes([]); }} > } /> 초기화 ); } ``` ### Alignment React's `alignItems` prop is not supported in Lynx List. In Lynx, the Recipe aligns prefix, content, and suffix to the center. If top alignment is needed, use a separate layout with low-level slots placed directly. ### Border Radius React's `itemBorderRadius` prop is not supported in Lynx List. Lynx items use the border radius value defined by the Recipe. For rounded cards, apply `border-radius` and `overflow: hidden` to the outer container. ## Customization and Composition ### Usage The `List` and `ListHeader` components provided by `@seed-design/lynx-react` 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 IconChevronRightLine from "@karrotmarket/lynx-monochrome-icon/IconChevronRightLine"; import IconPersonCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPersonCircleLine"; import { List, ListHeader, PrefixIcon, SuffixIcon } from "@seed-design/lynx-react"; My Information } /> My Profile Manage my information shown to others. } /> ``` - `ListHeader`: Header that displays the list title or description - `List.Root`: Container that wraps all list items - `List.Item`: Non-interactive individual item - `List.ButtonItem`: Individual item that can be tapped - `List.CheckboxItem`, `List.RadioItem`, `List.SwitchItem`: Individual items with selection state - `List.Prefix`: Start area that displays icons or Avatar, etc. - `List.Content`: Center area for title and description - `List.Suffix`: End area that displays icons or Action Button, etc. ### Combining with Appropriate Semantic Elements Using `asChild` Prop Lynx has no DOM-based `asChild` prop. Use interaction items that match the role directly. #### Using `List.ButtonItem` instead of `asChild` in `List.Content` Use `List.ButtonItem` when tapping the entire item. ```tsx import { List } from "@seed-design/lynx-react"; Users 6 items ``` The snippet's `ListButtonItem` helps write the same structure more simply. ```tsx import { ListButtonItem } from "@/components/ui/list"; ``` #### Using selection items instead of `asChild` in `List.Item` Use `List.CheckboxItem`, `List.RadioItem`, `List.SwitchItem` for items with selection state. The snippet's selection items configure accessibility values and default controls together. ```tsx import { ListCheckItem } from "@/components/ui/list"; ``` ## Web Version Differences | Area | React Web | Lynx | | --------------------- | ----------------------------- | ------------------------------------------ | | Elements | `ul`, `li`, `button`, `input` | `view`, `text` | | Events | `onClick` | `bindtap`, `main-thread:bindtap` | | Accessibility | HTML semantics and ARIA | `accessibility-*` | | Link items | `ListLinkItem` | Call app router from `ListButtonItem` | | Polymorphic rendering | `as`, `asChild` | Not supported | | Selection control | Hidden input | Lynx state and accessibility value sharing | ## Unsupported Lynx Features | Feature | Web Counterpart | Alternative | | ----------------------------- | --------------------------------- | ------------------------------------------------- | | `ListLinkItem` | `` link item | Call app router from `ListButtonItem`'s `bindtap` | | `itemBorderRadius` | List-specific press border radius | Apply radius and clipping to outer container | | `alignItems` | Prefix and suffix alignment | Separate layout using low-level slots | | Complex content inside Header | Title and action in one Header | Header and action as sibling elements |