ActionList
상호작용 가능한 동작이나 옵션의 세로 목록이에요. 아이콘, 설명, 사이드 정보, 기타 풍부한 비주얼을 담을 수 있는 일관된 단일 열 형식으로 제시된 항목(item)들로 구성됩니다.
이 페이지는 ActionList의 다양한 사용 예시(기본, 선행·후행 콘텐츠, 동작, 구분선, 설명, 선택, 그룹핑 등)와 전체 Props 문서를 다룹니다.
출처: 문서
본문
ActionList는 상호작용 가능한 동작이나 옵션의 세로 목록이에요. 아이콘, 설명, 사이드 정보, 기타 풍부한 비주얼을 담을 수 있는 일관된 단일 열 형식으로 제시된 항목들로 구성됩니다.
React 예시 (React examples)
기본 (Default)
ActionList의 가장 단순한 사용법이에요.
<ActionList>
<ActionList.Item>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
</ActionList>
선행·후행 콘텐츠가 있는 항목 (Items with leading and trailing content)
ActionList 항목은 항목 콘텐츠의 앞이나 뒤에, 보통 아이콘 같은 시각적 요소인 비상호작용 콘텐츠를 포함할 수 있어요. Leading visual 지침 / Trailing visual 및 trailing text 지침
<ActionList>
<ActionList.Item>
<ActionList.LeadingVisual>
<Avatar src="https://github.com/mona.png" />
</ActionList.LeadingVisual>
Item one
<ActionList.TrailingVisual>
<PencilIcon />
</ActionList.TrailingVisual>
</ActionList.Item>
<ActionList.Item>
<ActionList.LeadingVisual>
<Avatar src="https://github.com/mona.png" />
</ActionList.LeadingVisual>
Item two
<ActionList.TrailingVisual>
<PencilIcon />
</ActionList.TrailingVisual>
</ActionList.Item>
<ActionList.Item>
<ActionList.LeadingVisual>
<Avatar src="https://github.com/mona.png" />
</ActionList.LeadingVisual>
Item three
<ActionList.TrailingVisual>
<PencilIcon />
</ActionList.TrailingVisual>
</ActionList.Item>
</ActionList>
후행 동작이 있는 항목 (Items with trailing actions)
후행 비주얼과 비슷하지만, 활성화되면 보조(secondary) 동작을 트리거해요. Trailing action 지침
<ActionList>
<ActionList.Item>
Item one
<ActionList.TrailingAction label="Expand sidebar" icon={ArrowLeftIcon} />
</ActionList.Item>
<ActionList.Item>
Item two (with link TrailingAction)
<ActionList.TrailingAction as="a" href="#" label="Some action two" icon={ArrowRightIcon} />
</ActionList.Item>
<ActionList.Item>
Item three
<ActionList.TrailingAction label="Some action three" icon={BookIcon} />
</ActionList.Item>
</ActionList>
구분선이 있는 항목 (Items with dividers)
<ActionList showDividers>
<ActionList.Item>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
</ActionList>
인라인 설명이 있는 항목 (Items with inline descriptions)
<ActionList>
<ActionList.Item>
Item one
<ActionList.Description>Lorem ipsum dolor</ActionList.Description>
</ActionList.Item>
<ActionList.Item>
Item two
<ActionList.Description>Sit amet consectetur</ActionList.Description>
</ActionList.Item>
<ActionList.Item>
Item three
<ActionList.Description>Adipiscing elit</ActionList.Description>
</ActionList.Item>
</ActionList>
블록 설명이 있는 항목 (Items with block descriptions)
<ActionList>
<ActionList.Item>
Item one
<ActionList.Description variant="block">Lorem ipsum dolor</ActionList.Description>
</ActionList.Item>
<ActionList.Item>
Item two
<ActionList.Description variant="block">Sit amet consectetur</ActionList.Description>
</ActionList.Item>
<ActionList.Item>
Item three
<ActionList.Description variant="block">Adipiscing elit</ActionList.Description>
</ActionList.Item>
</ActionList>
위험(danger) 항목 (With a danger item)
사용자의 특별한 주의가 필요한 동작을 강조하는 데 사용하는 변형이에요. Danger item 지침
<ActionList>
<ActionList.Item>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
<ActionList.Item variant="danger">Delete</ActionList.Item>
</ActionList>
비활성(inactive) 항목 (With an inactive item)
장애(outage) 같은 시스템 상태 때문에 기능하지 않는 비활성 항목이에요. Inactive item 지침
<ActionList>
<ActionList.Item inactiveText="Unavailable due to an outage">Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
</ActionList>
로딩 항목 (With a loading item)
<ActionList>
<ActionList.Item loading>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
</ActionList>
비활성화(disabled) 항목 (With a disabled item)
<ActionList>
<ActionList.Item disabled>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
</ActionList>
단일 선택 (Single-select)
import React from 'react'
import {ActionList} from '@primer/react'
const items = [{label: 'Item one'}, {label: 'Item two'}, {label: 'Item three'}]
export default function SingleSelect() {
const [selectedIndex, setSelectedIndex] = React.useState(0)
return (
<ActionList selectionVariant="single" role="menu" aria-label="Item">
{items.map((item, index) => (
<ActionList.Item
key={index}
role="menuitemradio"
selected={index === selectedIndex}
aria-checked={index === selectedIndex}
onSelect={() => setSelectedIndex(index)}
>
{item.label}
</ActionList.Item>
))}
</ActionList>
)
}
다중 선택 (Multi-select)
import React from 'react'
import {ActionList} from '@primer/react'
const items = [{label: 'Item one'}, {label: 'Item two'}, {label: 'Item three'}]
export default function MultiSelect() {
const [selectedIndices, setSelectedIndices] = React.useState<Set<number>>(() => new Set([0]))
const handleSelect = (index: number): void => {
const newSelectedIndices = new Set(selectedIndices)
if (selectedIndices.has(index)) {
newSelectedIndices.delete(index)
} else {
newSelectedIndices.add(index)
}
setSelectedIndices(newSelectedIndices)
}
return (
<ActionList selectionVariant="multiple" role="menu" aria-label="Item">
{items.map((item, index) => (
<ActionList.Item
key={index}
role="menuitemcheckbox"
selected={selectedIndices.has(index)}
aria-checked={selectedIndices.has(index)}
onSelect={() => handleSelect(index)}
>
{item.label}
</ActionList.Item>
))}
</ActionList>
)
}
제목으로 항목 그룹핑 (Grouping items with a heading)
<ActionList>
<ActionList.Group>
<ActionList.GroupHeading as="h3">Items</ActionList.GroupHeading>
<ActionList.Item>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
</ActionList.Group>
<ActionList.Group>
<ActionList.GroupHeading as="h3">Listings</ActionList.GroupHeading>
<ActionList.Item>Listing one</ActionList.Item>
<ActionList.Item>Listing two</ActionList.Item>
<ActionList.Item>Listing three</ActionList.Item>
</ActionList.Group>
</ActionList>
구분선으로 항목 그룹핑 (Grouping items with a divider)
<ActionList>
<ActionList.Item>Item one</ActionList.Item>
<ActionList.Item>Item two</ActionList.Item>
<ActionList.Item>Item three</ActionList.Item>
<ActionList.Divider />
<ActionList.Item>Item four</ActionList.Item>
<ActionList.Item>Item five</ActionList.Item>
<ActionList.Item>Item six</ActionList.Item>
<ActionList.Divider />
<ActionList.Item variant="danger">Delete</ActionList.Item>
</ActionList>
추가 코드 예시 (More code examples)
위 예시는 ActionList 컴포넌트 전체 기능의 엄선된 부분집합이에요. 더 많은 예시는 ActionList Storybook 스토리를 참고하세요.
Props
ActionList
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | `ActionList.Item[] |
variant |
'inset' |
`'inset' |
selectionVariant |
— | `'single' |
showDividers |
— | boolean — 이 List에서 Header나 Divider를 따르지 않는 각 Item 위에 구분선을 표시해요. |
role |
— | AriaRole — 목록의 기능을 설명하는 ARIA 역할. listbox와 menu가 흔한 값이에요. |
disableItemGap |
false |
boolean — 이 ActionList가 NavList 안에서 렌더링될 때 항목 간 간격을 비활성화해요. |
ActionList.Item
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | `React.ReactNode |
variant |
'default' |
`'default' |
size |
'medium' |
`'medium' |
onSelect |
— | `(event: React.MouseEvent |
selected |
false |
boolean — 항목이 선택됐는지. 선택 가능한 항목에만 적용돼요. |
active |
false |
boolean — 항목이 활성인지. 활성 항목은 둘 이상이어선 안 돼요. |
disabled |
false |
boolean — 비활성화된 항목은 클릭, 선택, 탐색할 수 없어요. |
inactiveText |
— | string — 항목이 비활성인 이유를 설명하는 텍스트. 데이터베이스 장애 같은 시스템 오류로 항목의 평소 기능을 사용할 수 없을 때 쓰일 수 있어요. 선행 비주얼이 있으면 경고 아이콘이 그 자리를 대체하고, 후행 비주얼이 있으면 대체하며, 비주얼이 없으면 항목 콘텐츠의 왼쪽 정렬을 유지하기 위해 후행 비주얼 자리에 표시돼요. 텍스트는 ActionList 항목에서는 경고 아이콘으로 트리거되는 툴팁에 나타나고, ActionMenu 항목에서는 설명이나 제목 아래에 나타나요. |
loading |
— | boolean — 항목이 로딩 중인지. |
role |
— | AriaRole — 항목의 기능을 설명하는 ARIA 역할. option이 흔한 값이에요. |
id |
— | string — Item의 루트 요소에 붙일 id. |
ActionList.Heading
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | React.ReactNode — 목록에 제목을 주기 위해 사용. |
as |
h3 |
`h1 |
visuallyHidden |
— | boolean — 시각적으로 숨김. |
ActionList.LinkItem
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | `React.ReactNode |
active |
false |
boolean — 항목이 활성인지. 둘 이상이어선 안 돼요. |
ref |
— | React.RefObject<HTMLAnchorElement> |
as |
"a" |
React.ElementType |
inactiveText |
— | string — 항목이 비활성인 이유를 설명하는 텍스트. 데이터베이스 장애 같은 시스템 오류로 사용할 수 없을 때 쓰일 수 있어요. 더 많은 prop 옵션은 <a> 참고. |
ActionList.LeadingVisual
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | React.ReactNode — 항목 텍스트 앞에 위치하는 아이콘(또는 유사한 것). |
ActionList.TrailingVisual
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | React.ReactNode — 항목 텍스트 뒤에 위치하는 비주얼. |
ActionList.TrailingAction
| 이름 | 기본값 | 설명 |
|---|---|---|
as |
button |
`a |
label |
Required | string — 컨트롤의 접근 가능한 이름. |
icon |
Required | string — IconButton에 전달할 Octicon. 설정하지 않으면 TrailingAction은 IconButton 대신 Button으로 렌더링돼요. |
href |
— | string — TrailingAction이 링크로 렌더링될 때의 href. |
loading |
false |
boolean — TrailingAction이 로딩 상태인지. true면 아이콘 대신 스피너를 렌더링해요. as가 'button'일 때만 사용 가능. |
tooltipDirection |
'w' |
`'n' |
ActionList.Description
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | React.ReactNode |
variant |
'inline' |
`'inline' |
className |
— | `string |
truncate |
false |
boolean — 인라인 설명이 오버플로 시 텍스트를 잘라낼지. |
ActionList.GroupHeading
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | React.ReactNode — 그룹에 제목을 주기 위해 사용. |
variant |
'subtle' |
`'filled' |
auxiliaryText |
— | string — Group에 대한 추가 정보를 제공하는 보조 텍스트. |
visuallyHidden |
— | boolean |
as |
h3 |
`h1 |
ActionList.Group
| 이름 | 기본값 | 설명 |
|---|---|---|
children |
Required | `ActionList.Item[] |
title |
Deprecated | string — ActionList.GroupHeading을 대신 사용하세요. |
auxiliaryText |
— | string — 그룹에 대한 추가 정보를 제공하는 보조 텍스트. |
variant |
'subtle' |
`'filled' |
selectionVariant |
— | `'single' |
role |
— | AriaRole — 그룹 안 목록의 기능을 설명하는 ARIA 역할. listbox와 menu가 흔한 값이에요. |
더 알아보기 (Learn more)
- ActionList 가이드라인 — 선행/후행 비주얼, 위험·비활성·로딩 항목, 선택 상태 지침.
- ActionList 접근성 — 키보드·스크린 리더 동작.
- ActionMenu — ActionList와 Overlay로 구성된 퀵 선택 메뉴.
- rails 구현은 Lookbook 문서를 참고하세요.