Breadcrumb는 탐색 계층 구조(navigational hierarchies)를 만들기 위한 styled가 없는 크럼브 컴포넌트예요. 레이아웃과 스타일을 완전히 제어하면서 시맨틱한 HTML 구조를 유지할 수 있어요.
출처: 문서
본문
기능 (Features)
- 하위 컴포넌트(
Root, List, Item, Link, Current, Separator, Ellipsis)로 구성된 compound 컴포넌트 API
nav > ol > li 계층 구조의 시맨틱 HTML
aria-current="page"를 사용한 현재 페이지 표시
- 접근성 트리에서 숨겨지는 장식용(요소용) 구분자(Separator)
사용법 (Usage)
import { Breadcrumb } from 'primereact/breadcrumb';
<Breadcrumb.Root>
<Breadcrumb.List>
<Breadcrumb.Item>
<Breadcrumb.Link></Breadcrumb.Link>
</Breadcrumb.Item>
<Breadcrumb.Separator></Breadcrumb.Separator>
<Breadcrumb.Item>
<Breadcrumb.Current></Breadcrumb.Current>
</Breadcrumb.Item>
</Breadcrumb.List>
</Breadcrumb.Root>
동작 (Behavior)
다형적 렌더링 (Polymorphic Rendering)
아무 하위 컴포넌트에 as를 사용해 렌더링되는 HTML 요소를 바꿀 수 있어요.
<Breadcrumb.Root as="div"></Breadcrumb.Root>
<Breadcrumb.Link as="button"></Breadcrumb.Link>
기본 요소: Root=nav, List=ol, Item=li, Link=a, Current=span, Separator=li, Ellipsis=span.
렌더 함수 자식 (Render Function Children)
Root는 렌더 함수를 자식으로 받아 컴포넌트 인스턴스에 접근할 수 있게 해 줘요.
<Breadcrumb.Root>{(instance) => <ol>{/* custom breadcrumb items */}</ol>}</Breadcrumb.Root>
패스 스루 (Pass Through)
<DocPTViewer name="breadcrumb-pt" components={['BreadcrumbRoot']} />
API
BreadcrumbRoot
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"root" |
| Label |
Type |
Description |
| root |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| list |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the list's DOM element. |
| item |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the item's DOM element. |
| separator |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the separator's DOM element. |
| link |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the link's DOM element. |
| current |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the current's DOM element. |
| ellipsis |
BreadcrumbRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the ellipsis's DOM element. |
BreadcrumbList
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"list" |
| Label |
Type |
Description |
| root |
BreadcrumbListPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
BreadcrumbItem
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"item" |
| Label |
Type |
Description |
| root |
BreadcrumbItemPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
BreadcrumbLink
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"link" |
| Label |
Type |
Description |
| root |
BreadcrumbLinkPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
BreadcrumbCurrent
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"current" |
| Label |
Type |
Description |
| root |
BreadcrumbCurrentPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
BreadcrumbSeparator
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"separator" |
| Label |
Type |
Description |
| root |
BreadcrumbSeparatorPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
BreadcrumbEllipsis
| Attribute |
Value |
data-scope |
"breadcrumb" |
data-part |
"ellipsis" |
| Label |
Type |
Description |
| root |
BreadcrumbEllipsisPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
접근성 (Accessibility)
스크린 리더 (Screen Reader)
루트 요소는 aria-label="Breadcrumb"를 가진 nav를 사용해 탐색 랜드마크를 나타내요. 목록은 시맨틱 ol > li 구조를 사용해요. 구분자(Separator)는 role="presentation"과 aria-hidden="true"를 가져서 스크린 리더가 건너뛰게 돼요. 현재 페이지는 aria-current="page"로 표시돼요.
키보드 지원 (Keyboard Support)
| Key |
Function |
tab |
Moves focus through the breadcrumb links. |
더 알아보기 (Learn more)