리스트와 그리드 레이아웃을 만들기 위한 데이터 컨테이너 컴포넌트로, 표현(presentation)을 완전히 제어할 수 있는 스타일 없는 컴포넌트예요.
출처: 문서
본문
특징 (Features)
- 서브 컴포넌트(
Root, Header, Content, Footer, Empty)를 가진 복합 컴포넌트 API
- 제어(controlled) 및 비제어(uncontrolled) 모드의 레이아웃 상태 관리
- 필드 기준으로 데이터를 정렬하는 로케일 인지
sort 유틸리티
- CSS 기반 레이아웃 전환을 위해
data-layout 속성에 반영되는 레이아웃 값
사용법 (Usage)
import { DataView } from 'primereact/dataview';
<DataView.Root>
<DataView.Header></DataView.Header>
<DataView.Content></DataView.Content>
<DataView.Footer></DataView.Footer>
<DataView.Empty></DataView.Empty>
</DataView.Root>
동작 (Behavior)
다형 렌더링 (Polymorphic Rendering)
어떤 서브 컴포넌트든 as를 사용해 렌더링되는 HTML 요소를 바꿀 수 있어요.
<DataView.Root as="section"></DataView.Root>
<DataView.Content as="ul"></DataView.Content>
기본 요소: Root=div, Header=div, Content=div, Footer=div, Empty=div.
렌더 함수 자식 (Render Function Children)
Root는 자식으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있게 해줘요.
<DataView.Root>{(instance) => <span>Layout: {instance.state.layout}</span>}</DataView.Root>
Pass Through
<DocPTViewer name="dataview-pt" components={['DataViewRoot']} />
API
DataViewRoot
| Attribute |
Value |
data-scope |
"dataview" |
data-part |
"root" |
data-layout |
Current layout value |
| Label |
Type |
Description |
| root |
DataViewRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| Attribute |
Value |
data-scope |
"dataview" |
data-part |
"header" |
| Label |
Type |
Description |
| root |
DataViewHeaderPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
DataViewContent
| Attribute |
Value |
data-scope |
"dataview" |
data-part |
"content" |
| Label |
Type |
Description |
| root |
DataViewContentPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| Attribute |
Value |
data-scope |
"dataview" |
data-part |
"footer" |
| Label |
Type |
Description |
| root |
DataViewFooterPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
DataViewEmpty
| Attribute |
Value |
data-scope |
"dataview" |
data-part |
"empty" |
| Label |
Type |
Description |
| root |
DataViewEmptyPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
접근성 (Accessibility)
스크린 리더 (Screen Reader)
DataView는 의미론적(semantic) div 컨테이너를 사용해요. 특정 데이터 레이아웃에 맞춰 role과 aria-label 속성을 필요한 대로 추가하세요.
<DataView.Root aria-label="Product list">
<DataView.Content role="list"></DataView.Content>
</DataView.Root>
키보드 지원 (Keyboard Support)
해당 없음. DataView는 프레젠테이션 용도 컨테이너이므로 키보드 상호작용은 내부에 렌더링되는 콘텐츠에 달려 있어요.
더 알아보기 (Learn more)