본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Panel — 패널

원문 보기 위키 갱신

접이식 콘텐츠를 선택적으로 제공하는 스타일 없고 접근 가능한 패널 컴포넌트예요.

출처: 문서

본문

레이아웃과 스타일링을 완전히 제어하며 완전히 커스텀한 콘텐츠 패널을 만들어 보세요.

기능 (Features)

  • 일곱 개의 하위 컴포넌트를 갖춘 복합 컴포넌트 API: Root, Header, Title, Trigger, Indicator, Content, Footer

사용법 (Usage)

import { Panel } from 'primereact/panel';
<Panel.Root>
    <Panel.Header>
        <Panel.Title />
        <Panel.Trigger>
            <Panel.Indicator />
        </Panel.Trigger>
    </Panel.Header>
    <Panel.Content />
    <Panel.Footer />
</Panel.Root>

동작 (Behavior)

모션 애니메이션 (Motion Animation)

열기/닫기 애니메이션을 구성하려면 Root에서 motionProps를 사용해요.

<Panel.Root motionProps={{ name: 'p-collapsible', cssVarPrefix: 'panel-content', hideStrategy: 'none' }}>...</Panel.Root>

애니메이션 단계, CSS 변수, 숨김 전략은 Motion을 참고해요.

다형성 렌더링 (Polymorphic Rendering)

어느 하위 컴포넌트에서든 as를 사용해 렌더링되는 HTML 요소를 바꿀 수 있어요.

<Panel.Root as="section">
    <Panel.Header as="nav">
        <Panel.Title as="h2">...</Panel.Title>
    </Panel.Header>
    <Panel.Content as="article">...</Panel.Content>
    <Panel.Footer as="nav">...</Panel.Footer>
</Panel.Root>

기본 요소: Root=div, Header=div, Title=div, Trigger=button, Content=div, Footer=div, Indicator=span.

렌더 함수 children (Render Function Children)

Content는 children으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있게 해줘요. 인스턴스는 panel(루트 인스턴스)과 motion(애니메이션 상태)을 노출해요.

<Panel.Content>{(instance) => <div>Panel is {instance.panel?.state.open ? 'open' : 'closed'}</div>}</Panel.Content>

패스 스루 (Pass Through)

<DocPTViewer name="panel-pt" components={['PanelRoot']} />

API

PanelRoot

Attribute Value
data-scope "panel"
data-part "root"
data-open Present when expanded
data-closed Present when collapsed
data-disabled Present when disabled
Label Type Description
root PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.
header PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the header's DOM element.
trigger PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the trigger's DOM element.
title PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the title's DOM element.
content PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the content's DOM element.
contentOuter PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the content outer wrapper's DOM element.
contentInner PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the content inner wrapper's DOM element.
footer PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the footer's DOM element.
indicator PanelRootPassThroughType<HTMLAttributes> Used to pass attributes to the indicator's DOM element.

PanelHeader

Label Type Description
root PanelHeaderPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

PanelTitle

Label Type Description
root PanelTitlePassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

PanelTrigger

Attribute Value
data-scope "panel"
data-part "trigger"
data-content-open Present when content open
data-content-closed Present when content closed
Label Type Description
root PanelTriggerPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

PanelIndicator

Attribute Value
data-scope "panel"
data-part "indicator"
data-open Present when expanded
data-closed Present when collapsed
Label Type Description
root PanelIndicatorPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

PanelContent

Attribute Value
data-scope "panel"
data-part "content"
data-open Present when expanded
data-closed Present when collapsed
Label Type Description
root PanelContentPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

PanelFooter

Label Type Description
root PanelFooterPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

접근성 (Accessibility)

스크린 리더 (Screen Reader)

토글 가능한 패널의 경우 트리거 버튼은 aria-controls로 콘텐츠 영역을 참조하고 aria-expanded로 표시 상태를 반영해요. 콘텐츠는 role="region"과 트리거의 aria-controls와 일치하는 id를 사용해요. 접근 가능한 라벨은 aria-label 또는 aria-labelledby로 커스터마이징할 수 있어요.

키보드 지원 (Keyboard Support)

Key Function
tab Moves focus to the next focusable element in the page tab sequence.
shift + tab Moves focus to the previous focusable element in the page tab sequence.
enter Toggles the visibility of the content.
space Toggles the visibility of the content.

더 알아보기 (Learn more)