Toolbar — 툴바
동작을 묶기 위한 복합 구성의 스타일 없는 툴바 컴포넌트예요.
출처: 문서
본문
콘텐츠 영역과 스타일링을 완전히 제어하며 완전히 커스텀한 툴바 레이아웃을 만들어 보세요.
기능 (Features)
- 네 개의 하위 컴포넌트를 갖춘 복합 컴포넌트 API:
Root,Start,Center,End - 시작·중앙·끝 콘텐츠 정렬을 위한 3-영역 레이아웃
Root에서 모든 하위 컴포넌트로 컨텍스트 공유
사용법 (Usage)
import { Toolbar } from 'primereact/toolbar';
<Toolbar.Root>
<Toolbar.Start />
<Toolbar.Center />
<Toolbar.End />
</Toolbar.Root>
동작 (Behavior)
다형성 렌더링 (Polymorphic Rendering)
어느 하위 컴포넌트에서든 as를 사용해 렌더링되는 HTML 요소를 바꿀 수 있어요.
<Toolbar.Root as="nav">
<Toolbar.Start as="ul">...</Toolbar.Start>
</Toolbar.Root>
기본 요소: Root=div, Start=div, Center=div, End=div.
렌더 함수 children (Render Function Children)
하위 컴포넌트는 children으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있게 해줘요.
<Toolbar.Start>{(instance) => <span>Toolbar ID: {instance.toolbar?.id}</span>}</Toolbar.Start>
패스 스루 (Pass Through)
<DocPTViewer name="toolbar-pt" components={['ToolbarRoot']} />
API
ToolbarRoot
| Attribute | Value |
|---|---|
data-scope |
toolbar |
data-part |
root |
| Label | Type | Description |
|---|---|---|
| root | ToolbarRootPassThroughType<HTMLAttributes> | Used to pass attributes to the root's DOM element. |
| start | ToolbarRootPassThroughType<HTMLAttributes> | Used to pass attributes to the start's DOM element. |
| center | ToolbarRootPassThroughType<HTMLAttributes> | Used to pass attributes to the center's DOM element. |
| end | ToolbarRootPassThroughType<HTMLAttributes> | Used to pass attributes to the end's DOM element. |
ToolbarStart
| Label | Type | Description |
|---|---|---|
| root | ToolbarStartPassThroughType<HTMLAttributes> | Used to pass attributes to the root's DOM element. |
ToolbarCenter
| Label | Type | Description |
|---|---|---|
| root | ToolbarCenterPassThroughType<HTMLAttributes> | Used to pass attributes to the root's DOM element. |
ToolbarEnd
| Label | Type | Description |
|---|---|---|
| root | ToolbarEndPassThroughType<HTMLAttributes> | Used to pass attributes to the root's DOM element. |
접근성 (Accessibility)
스크린 리더 (Screen Reader)
Toolbar는 루트 요소에 role="toolbar"를 사용해요. 기본값이 "horizontal"이므로 aria-orientation은 포함되지 않아요. Root에 aria-label 또는 aria-labelledby로 접근 가능한 라벨을 제공해요.
키보드 지원 (Keyboard Support)
컴포넌트는 내장 키보드 상호작용을 포함하지 않아요. 키보드 동작은 툴바 안에 배치된 상호작용 요소(버튼, 입력 등)에 달려 있어요. 필요하다면 WAI-ARIA Toolbar Pattern을 따라 화살표 키로 포커스를 관리해요.