스플리터
스플리터 (Splitter)
스플리터는 화면 영역을 여러 패널로 나누고, 패널 사이 경계를 드래그해서 크기를 조절할 수 있게 해주는 컴포넌트예요. 기본은 가로 배치이고 layout 속성으로 세로 배치로 바꿀 수 있으며, 여러 스플리터를 중첩하면 복잡한 레이아웃도 만들 수 있어요. 패널 크기는 panelSizes, 최소 크기는 minSizes로 제어하고 키보드 접근성도 지원해요. 이 문서에서는 가로·세로·중첩 사용법부터 Props, Emits, Pass Through, 테마 설정까지 살펴봐요
출처: 문서
본문
접근성
스크린 리더 스플리터 바는 role을 separator로 정의하며, aria-orientation은 horizontal 또는 vertical로 설정돼요. 키보드 지원 키 기능 tab은 스플리터 바 사이에서 포커스를 이동해요. 아래쪽 화살표는 수직 스플리터를 아래로 이동해요. 위쪽 화살표는 수직 스플리터를 위로 이동해요. 왼쪽 화살표는 수직 스플리터를 왼쪽으로 이동해요. 오른쪽 화살표는 수직 스플리터를 오른쪽으로 이동해요.
가로
Splitter는 자식으로 두 개의 SplitterPanel 컴포넌트를 필요로 하며, 이 컴포넌트들은 기본적으로 가로 방향으로 표시돼요.
import { Component } from '@angular/core';
import { SplitterModule } from 'primeng/splitter';
@Component({
template: `
<div class="card">
<p-splitter [style]="{ height: '300px' }" class="mb-8">
<ng-template #panel>
<div class="flex items-center justify-center h-full">Panel 1</div>
</ng-template>
<ng-template #panel>
<div class="flex items-center justify-center h-full">Panel 2</div>
</ng-template>
</p-splitter>
</div>
`,
standalone: true,
imports: [SplitterModule]
})
export class SplitterHorizontalDemo {}
중첩
Splitter를 조합하면 고급 레이아웃을 만들 수 있어요.
import { Component } from '@angular/core';
import { SplitterModule } from 'primeng/splitter';
@Component({
template: `
<div class="card">
<p-splitter [style]="{ height: '300px' }" [panelSizes]="[20, 80]" [minSizes]="[10, 0]" class="mb-8">
<ng-template #panel>
<div class="col flex w-full items-center justify-center">Panel 1</div>
</ng-template>
<ng-template #panel>
<p-splitter layout="vertical" [panelSizes]="[50, 50]">
<ng-template #panel>
<div style="flex-grow: 1;" class="flex items-center justify-center">Panel 2</div>
</ng-template>
<ng-template #panel>
<p-splitter [panelSizes]="[20, 80]">
<ng-template #panel>
<div class="col h-full flex items-center justify-center">Panel 3</div>
</ng-template>
<ng-template #panel>
<div class="col h-full flex items-center justify-center">Panel 4</div>
</ng-template>
</p-splitter>
</ng-template>
</p-splitter>
</ng-template>
</p-splitter>
</div>
`,
standalone: true,
imports: [SplitterModule]
})
export class SplitterNestedDemo {}
크기
panelSizes가 정의되어 있지 않으면 패널이 50/50으로 분할돼요. panelSizes 속성을 사용해서 상대적인 너비를 지정하세요. 예를 들어 [25, 75]처럼요.
import { Component } from '@angular/core';
import { SplitterModule } from 'primeng/splitter';
@Component({
template: `
<div class="card">
<p-splitter [panelSizes]="[25, 75]" [style]="{ height: '300px' }" class="mb-8">
<ng-template #panel>
<div class="flex items-center justify-center h-full">Panel 1</div>
</ng-template>
<ng-template #panel>
<div class="flex items-center justify-center h-full">Panel 2</div>
</ng-template>
</p-splitter>
</div>
`,
standalone: true,
imports: [SplitterModule]
})
export class SplitterSizeDemo {}
세로
layout을 vertical로 설정하면 패널이 위아래로 쌓인 형태로 표시돼요.
import { Component } from '@angular/core';
import { SplitterModule } from 'primeng/splitter';
@Component({
template: `
<div class="card">
<p-splitter [style]="{ height: '300px' }" class="mb-8" [panelSizes]="[50, 50]" layout="vertical">
<ng-template #panel>
<div class="flex items-center justify-center h-full">Panel 1</div>
</ng-template>
<ng-template #panel>
<div class="flex items-center justify-center h-full">Panel 2</div>
</ng-template>
</p-splitter>
</div>
`,
standalone: true,
imports: [SplitterModule]
})
export class SplitterVerticalDemo {}
Splitter
Splitter는 패널을 분리하고 크기를 조정하는 데 사용돼요.
프로퍼티
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| dt | InputSignal | undefined | 컴포넌트의 스코프 디자인 토큰을 정의해요. |
| unstyled | InputSignal | undefined | 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요. |
| pt | InputSignal | undefined | 컴포넌트 내부의 DOM 엘리먼트에 속성을 전달하는 데 사용돼요. |
| ptOptions | InputSignal | undefined | 컴포넌트의 passthrough(pt) 옵션을 구성하는 데 사용돼요. |
| styleClass | string | - | 컴포넌트의 스타일 클래스예요. (지원 중단됨) |
| panelStyleClass | string | - | 패널의 스타일 클래스예요. |
| panelStyle | { [klass: string]: any } | - | 패널의 인라인 스타일이에요. |
| stateStorage | string | session | 상태를 유지하는 splitter가 상태를 저장할 위치를 정의해요. 유효한 값은 sessionStorage를 위한 'session'과 localStorage를 위한 'local'이에요. |
| stateKey | string | null | 상태를 유지하는 Splitter의 저장소 식별자예요. |
| layout | string | horizontal | 패널의 방향이에요. 유효한 값은 'horizontal'과 'vertical'이에요. |
| gutterSize | number | 4 | 구분선의 픽셀 단위 크기예요. |
| step | number | 5 | 방향키를 누르는 동안 패널 크기를 증가/감소시키는 단계 값이에요. |
| minSizes | number[] | [] | 100%를 기준으로 한 요소의 최소 크기예요. |
| panelSizes | number[] | - | 100%를 기준으로 한 요소의 크기예요. |
이벤트
| 이름 | 파라미터 | 설명 |
|---|---|---|
| onResizeEnd | event: SplitterResizeEndEvent | 리사이즈가 끝날 때 호출되는 콜백이에요. |
| onResizeStart | event: SplitterResizeStartEvent | 리사이즈가 시작할 때 호출되는 콜백이에요. |
패스 스루 옵션
| 이름 | 타입 | 설명 |
|---|---|---|
| root | PassThroughOption<HTMLElement, I> | 루트의 DOM 엘리먼트에 속성을 전달하는 데 사용돼요. |
| panel | PassThroughOption<HTMLDivElement, I> | 패널의 DOM 엘리먼트에 속성을 전달하는 데 사용돼요. |
| gutter | PassThroughOption<HTMLDivElement, I> | 거터의 DOM 엘리먼트에 속성을 전달하는 데 사용돼요. |
| gutterHandle | PassThroughOption<HTMLDivElement, I> | 거터 핸들의 DOM 엘리먼트에 속성을 전달하는 데 사용돼요. |
테마
CSS 클래스
| 클래스 | 설명 |
|---|---|
| p-splitter | 루트 엘리먼트의 클래스 이름이에요. |
| p-splitter-gutter | 거터 엘리먼트의 클래스 이름이에요. |
| p-splitter-gutter-handle | 거터 핸들 엘리먼트의 클래스 이름이에요. |
디자인 토큰
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| splitter.background | --p-splitter-background | 루트의 배경이에요. |
| splitter.border.color | --p-splitter-border-color | 루트의 테두리 색상이에요. |
| splitter.color | --p-splitter-color | 루트의 색상이에요. |
| splitter.transition.duration | --p-splitter-transition-duration | 루트의 전환 지속 시간이에요. |
| splitter.gutter.background | --p-splitter-gutter-background | 거터의 배경이에요. |
| splitter.handle.size | --p-splitter-handle-size | 핸들의 크기예요. |
| splitter.handle.background | --p-splitter-handle-background | 핸들의 배경이에요. |
| splitter.handle.border.radius | --p-splitter-handle-border-radius | 핸들의 테두리 반경이에요. |
| splitter.handle.focus.ring.width | --p-splitter-handle-focus-ring-width | 핸들의 포커스 링 너비예요. |
| splitter.handle.focus.ring.style | --p-splitter-handle-focus-ring-style | 핸들의 포커스 링 스타일이에요. |
| splitter.handle.focus.ring.color | --p-splitter-handle-focus-ring-color | 핸들의 포커스 링 색상이에요. |
| splitter.handle.focus.ring.offset | --p-splitter-handle-focus-ring-offset | 핸들의 포커스 링 오프셋이에요. |
| splitter.handle.focus.ring.shadow | --p-splitter-handle-focus-ring-shadow | 핸들의 포커스 링 그림자예요. |
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.