Item

선택적 선행 미디어, 콘텐츠 열, 후행 액션을 갖춘 유연한 목록 행 프리미티브입니다.

개요

Item은 유연한 목록 행 프리미티브예요: 선택적 선행 미디어, 늘어나는 콘텐츠 열, 후행 액션의 가로 띠예요. ItemMedia, ItemContent, ItemTitle, ItemDescription, ItemActions로 조합하세요. 설정 행, 멤버 목록, 선택 가능한 옵션, 유사한 목록형 UI에 사용하세요.

구조

세 개의 선택적 슬롯을 좌에서 우로 배치하는 flex 행(<div>)이에요:

outline 변형은 @ghds/sketch-core를 통해 손그림 테두리를 그려요; 모든 색상, 간격, 스케치 파라미터는 @ghds/tokens(comp.item.*)에서 와요.

변형 및 상태

세 가지 표면 변형 — default(투명), muted(은은한 채우기), outline(손그림 테두리) — 에 더해 선택된 배경을 채우는 selected 불린이 있어요.

State Status Notes
Selected Implemented selected 불린이 comp.item.bg.selected를 채워요.
Hover Not implemented Item 자체는 hover 상태를 그리지 않아요 — 필요하면 조합에서 연결하세요.
Focus Not implemented 일반 div를 렌더해요; 인터랙티브하게 만들 때 포커스 스타일을 추가하세요.
비활성화 Not implemented —
로딩 Not implemented —
오류 Not implemented —

사용법

Do

  • 원시 div를 스타일링하지 말고 ItemMedia / ItemContent / ItemTitle / ItemDescription / ItemActions로 행을 조합하세요.
  • 목록이 사용되는 방식에 맞게 컨테이너에 적절한 role(listitem, option 등)을 설정하세요.
  • 행이 선택 가능한 옵션일 때 selected를 aria-selected와 함께 사용하세요.

Don't

  • 인터랙션 시맨틱을 Item에 의존하지 마세요 — 일반 div를 렌더하므로 role, tabIndex, 핸들러를 직접 추가하세요.
  • 같은 목록에서 outline과 비-outline 행을 섞지 마세요; 일관된 리듬을 위해 목록당 하나의 변형을 유지하세요.

접근성

콘텐츠

ItemTitle은 주요 줄이에요 — 문장이 아닌 짧은 라벨. ItemDescription은 보조 정보를 위한 은은한 두 번째 줄이에요. 행이 스캔하기 좋도록 미디어는 아이콘/아바타 하나로, 액션은 한두 개의 컨트롤로 유지하세요.

Props API

React@ghds/react

PropTypeDefaultDescription
variant'default' | 'muted' | 'outline''default'표면 처리: 투명, 은은한 채우기, 손그림 테두리.
selectedbooleanfalse행을 선택된/활성 행으로 표시해요(선택된 배경을 채워요).
...restHTMLAttributes<HTMLDivElement>—네이티브 <div> 속성(role, onClick, tabIndex 등)이 전달돼요.

Web Components@ghds/web-components

PropTypeDefaultDescription
variant'default' | 'muted' | 'outline''default'reflected 속성; 표면 처리.
selectedbooleanfalsereflected 속성; 선택된 배경을 채워요.
slotsmedia, title, description, (default), actions—media / title / description / actions 슬롯에 콘텐츠를 넣어요; 기본 슬롯은 추가 본문 콘텐츠예요.

React Native@ghds/react-native

PropTypeDefaultDescription
variant'default' | 'muted' | 'outline''default'표면 처리.
selectedbooleanfalse선택된 배경을 채워요.
onPress(event: GestureResponderEvent) => void—설정되면 행이 버튼(Pressable)으로 노출돼요.
childrenReactNode—ItemMedia / ItemContent / ItemTitle / ItemDescription / ItemActions로 조합하세요.
accessibilityLabelstring—행의 접근 가능한 라벨.
testIDstring—쿼리용 테스트 핸들.

하위 컴포넌트 — ItemMedia, ItemContent, ItemTitle, ItemDescription, ItemActions — 는 각각 표준 HTMLAttributes<HTMLDivElement>를 받고 스타일이 지정된 <div>를 렌더해요.

코드 예시

// React — @ghds/react
import { Item, ItemContent, ItemTitle, ItemDescription, ItemActions } from '@ghds/react/item';
import { Badge } from '@ghds/react/badge';

<Item variant="outline">
  <ItemContent>
    <ItemTitle>GyeongHo Kim</ItemTitle>
    <ItemDescription>Maintainer · 3 open PRs</ItemDescription>
  </ItemContent>
  <ItemActions>
    <Badge variant="success">Online</Badge>
  </ItemActions>
</Item>;
<!-- Web Components — @ghds/web-components -->
<script type="module">
  import '@ghds/web-components/item';
</script>
<gh-item variant="outline">
  <span slot="title">GyeongHo Kim</span>
  <span slot="description">Maintainer · 3 open PRs</span>
</gh-item>
// React Native — @ghds/react-native
import { Item, ItemContent, ItemTitle, ItemDescription } from '@ghds/react-native/item';

<Item variant="outline" onPress={() => {}} accessibilityLabel="GyeongHo Kim">
  <ItemContent>
    <ItemTitle>GyeongHo Kim</ItemTitle>
    <ItemDescription>Maintainer · 3 open PRs</ItemDescription>
  </ItemContent>
</Item>;

라이브 데모

아래에서 React와 Web Components가 동일한 토큰으로 구동되며 라이브 렌더돼요 — 헤더에서 다크 모드를 토글하면 둘 다 동일하게 반응해요. React Native는 추가 react-native-web 연결 없이는 브라우저에서 실행할 수 없어요(이 사이트에 설정되지 않음), 따라서 사용법은 코드 샘플로 보여줘요.

React @ghds/react

Web Components @ghds/web-components

GH
GyeongHo Kim Maintainer · 3 open PRs
Muted row A subtle filled background. Selected row Marked as the active choice.