패널
패널 (Panel)
패널(Panel)은 콘텐츠를 담는 컨테이너 컴포넌트로, 헤더의 토글 버튼을 통해 내용을 접었다 펼 수 있는 기능을 선택적으로 제공해요. header와 footer 템플릿으로 상단·하단 영역을 자유롭게 꾸미고, toggleable 속성으로 접기 가능한 패널도 간단하게 만들 수 있어요. 이 문서에서는 기본 사용법부터 스크린 리더 접근성, Props·Emits·Templates 같은 API 옵션, 패스 스루와 디자인 토큰을 활용한 테마 설정까지 차근차근 설명해요
출처: 문서
본문
Accessibility
스크린 리더 토글 가능한 패널은 헤더에 콘텐츠 토글 버튼을 사용해요. 이 버튼은 aria-controls로 콘텐츠 섹션의 id를 정의하고, 가시성 상태를 나타내는 aria-expanded도 함께 가져요. 버튼을 읽을 때의 값은 기본적으로 header 프로퍼티의 값을 따르며, toggleButtonProps 프로퍼티를 통해 aria-label 또는 aria-labelledby를 정의해서 커스터마이즈할 수 있어요. 콘텐츠는 region을 사용하고, 콘텐츠 토글 버튼의 aria-controls와 일치하는 id를 정의하며, 헤더의 id를 참조하는 aria-labelledby를 가져요. 콘텐츠 토글 버튼 키보드 지원 키 기능 tab 페이지 탭 시퀀스에서 다음 포커스 가능한 요소로 포커스를 이동해요. shift + tab 페이지 탭 시퀀스에서 이전 포커스 가능한 요소로 포커스를 이동해요. enter 콘텐츠의 가시성을 토글해요. space 콘텐츠의 가시성을 토글해요.
Basic
header 프로퍼티와 children으로 전달되는 콘텐츠를 사용해 간단한 Panel을 만들 수 있어요.
import { Component } from '@angular/core';
import { PanelModule } from 'primeng/panel';
@Component({
template: `
<div class="card flex justify-center">
<p-panel header="Header">
<p class="m-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</p-panel>
</div>
`,
standalone: true,
imports: [PanelModule]
})
export class PanelBasicDemo {}
Template
header와 footer 템플릿을 사용해서 헤더와 푸터 섹션을 커스터마이즈할 수 있어요.
import { Component, OnInit } from '@angular/core';
import { AvatarModule } from 'primeng/avatar';
import { ButtonModule } from 'primeng/button';
import { MenuModule } from 'primeng/menu';
import { PanelModule } from 'primeng/panel';
@Component({
template: `
<div class="card">
<p-panel [toggleable]="true">
<ng-template #header>
<div class="flex items-center gap-2">
<p-avatar image="https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png" shape="circle" />
<span class="font-bold">Amy Elsner</span>
</div>
</ng-template>
<ng-template #footer>
<div class="flex flex-wrap items-center justify-between gap-4">
<div class="flex items-center gap-2">
<p-button icon="pi pi-user" rounded text></p-button>
<p-button icon="pi pi-bookmark" severity="secondary" rounded text></p-button>
</div>
<span class="text-surface-500 dark:text-surface-400">Updated 2 hours ago</span>
</div>
</ng-template>
<ng-template #icons>
<p-button icon="pi pi-cog" severity="secondary" rounded text (click)="menu.toggle($event)" />
<p-menu #menu id="config_menu" [model]="items" [popup]="true" />
</ng-template>
<p class="m-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</p-panel>
</div>
`,
standalone: true,
imports: [AvatarModule, ButtonModule, MenuModule, PanelModule]
})
export class PanelTemplateDemo implements OnInit {
ngOnInit() {
this.items = [
{
label: 'Refresh',
icon: 'pi pi-refresh'
},
{
label: 'Search',
icon: 'pi pi-search'
},
{
separator: true
},
{
label: 'Delete',
icon: 'pi pi-times'
}
];
}
}
Toggleable
toggleable 옵션을 사용하면 패널의 콘텐츠를 펼치고 접을 수 있고, 기본 상태는 collapsed 옵션으로 정의해요. 기본적으로는 토글 아이콘으로 콘텐츠를 토글하지만, toggler를 "header"로 설정하면 헤더의 어느 곳을 클릭하든 토글이 트리거돼요.
import { Component } from '@angular/core';
import { PanelModule } from 'primeng/panel';
@Component({
template: `
<div class="card">
<p-panel header="Header" [toggleable]="true">
<p class="m-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</p-panel>
</div>
`,
standalone: true,
imports: [PanelModule]
})
export class PanelToggleableDemo {}
Panel
Panel은 콘텐츠 토글 기능을 선택적으로 제공하는 컨테이너예요.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| dt | InputSignal | undefined | 컴포넌트의 스코프 디자인 토큰을 정의해요. |
| unstyled | InputSignal | undefined | 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요. |
| pt | InputSignal | undefined | 컴포넌트 내부의 DOM 요소에 속성을 전달하는 데 사용해요. |
| ptOptions | InputSignal | undefined | 컴포넌트의 passthrough(pt) 옵션을 구성하는 데 사용해요. |
| toggleable | boolean | false | 패널의 콘텐츠를 펼치고 접을 수 있는지 정의해요. |
| _header | string | - | 패널의 헤더 텍스트예요. |
| collapsed | boolean | - | 패널 콘텐츠의 초기 상태를 정의하며, 단방향 또는 양방향 바인딩도 지원해요. |
| styleClass | string | - | 컴포넌트의 스타일 클래스예요. (지원 중단) |
| iconPos | "center" | "start" | "end" | end | 아이콘의 위치예요. |
| showHeader | boolean | true | 패널의 헤더를 표시하지 않을지 여부를 지정해요. |
| toggler | "icon" | "header" | icon | 패널 콘텐츠를 토글할 토글러 요소를 지정해요. |
| transitionOptions | string | 400ms cubic-bezier(0.86, 0, 0.07, 1) | 애니메이션의 전환 옵션이에요. (지원 중단) |
| toggleButtonProps | any | - | ButtonProps의 모든 프로퍼티를 Button 컴포넌트에 전달하는 데 사용해요. |
| motionOptions | InputSignal | ... | 모션 옵션이에요. |
Emits
| Name | Parameters | Description |
|---|---|---|
| collapsedChange | value: boolean | collapsed가 변경될 때 발생해요. |
| onBeforeToggle | event: PanelBeforeToggleEvent | 패널 토글 전에 호출되는 콜백이에요. |
| onAfterToggle | event: PanelAfterToggleEvent | 패널 토글 후에 호출되는 콜백이에요. |
Templates
| Name | Type | Description |
|---|---|---|
| header | TemplateRef | 헤더의 템플릿 옵션을 정의해요. |
| icons | TemplateRef | 아이콘의 템플릿 옵션을 정의해요. |
| content | TemplateRef | 콘텐츠의 템플릿 옵션을 정의해요. |
| footer | TemplateRef | 푸터의 템플릿 옵션을 정의해요. |
| headericons | TemplateRef | headerIcon의 템플릿 옵션을 정의해요. |
Pass Through Options
| Name | Type | Description |
|---|---|---|
| host | PassThroughOption<HTMLElement, I> | 호스트의 DOM 요소에 속성을 전달하는 데 사용해요. |
| root | PassThroughOption<HTMLElement, I> | 루트의 DOM 요소에 속성을 전달하는 데 사용해요. |
| header | PassThroughOption<HTMLDivElement, I> | 헤더의 DOM 요소에 속성을 전달하는 데 사용해요. |
| title | PassThroughOption<HTMLSpanElement, I> | 타이틀의 DOM 요소에 속성을 전달하는 데 사용해요. |
| headerActions | PassThroughOption<HTMLDivElement, I> | 헤더 액션의 DOM 요소에 속성을 전달하는 데 사용해요. |
| pcToggleButton | ButtonPassThrough | 토글 버튼의 DOM 요소에 속성을 전달하는 데 사용해요. |
| contentContainer | PassThroughOption<HTMLDivElement, I> | 콘텐츠 컨테이너의 DOM 요소에 속성을 전달하는 데 사용해요. |
| contentWrapper | PassThroughOption<HTMLDivElement, I> | 콘텐츠 래퍼의 DOM 요소에 속성을 전달하는 데 사용해요. |
| content | PassThroughOption<HTMLDivElement, I> | 콘텐츠의 DOM 요소에 속성을 전달하는 데 사용해요. |
| footer | PassThroughOption<HTMLDivElement, I> | 푸터의 DOM 요소에 속성을 전달하는 데 사용해요. |
| motion | MotionOptions | 모션 컴포넌트/디렉티브에 옵션을 전달하는 데 사용해요. |
Theming
CSS Classes
| Class | Description |
|---|---|
| p-panel | 루트 요소의 클래스 이름 |
| p-panel-header | 헤더 요소의 클래스 이름 |
| p-panel-title | 타이틀 요소의 클래스 이름 |
| p-panel-header-actions | 헤더 액션 요소의 클래스 이름 |
| p-panel-toggle-button | 토글 버튼 요소의 클래스 이름 |
| p-panel-content-container | 콘텐츠 컨테이너 요소의 클래스 이름 |
| p-panel-content-wrapper | 콘텐츠 래퍼 요소의 클래스 이름 |
| p-panel-content | 콘텐츠 요소의 클래스 이름 |
| p-panel-footer | 푸터 요소의 클래스 이름 |
Design Tokens
| Token | CSS Variable | Description |
|---|---|---|
| panel.background | --p-panel-background | 루트의 배경 |
| panel.border.color | --p-panel-border-color | 루트의 테두리 색상 |
| panel.color | --p-panel-color | 루트의 색상 |
| panel.border.radius | --p-panel-border-radius | 루트의 테두리 반경 |
| panel.header.background | --p-panel-header-background | 헤더의 배경 |
| panel.header.color | --p-panel-header-color | 헤더의 색상 |
| panel.header.padding | --p-panel-header-padding | 헤더의 패딩 |
| panel.header.border.color | --p-panel-header-border-color | 헤더의 테두리 색상 |
| panel.header.border.width | --p-panel-header-border-width | 헤더의 테두리 두께 |
| panel.header.border.radius | --p-panel-header-border-radius | 헤더의 테두리 반경 |
| panel.toggleable.header.padding | --p-panel-toggleable-header-padding | 토글 가능한 헤더의 패딩 |
| panel.title.font.weight | --p-panel-title-font-weight | 타이틀의 글꼴 두께 |
| panel.content.padding | --p-panel-content-padding | 콘텐츠의 패딩 |
| panel.footer.padding | --p-panel-footer-padding | 푸터의 패딩 |
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.