Splitter
Splitter는 패널을 분리하고 크기를 조절할 수 있게 해주는 컴포넌트예요. 레이아웃을 나누고 사용자가 끌어서 각 영역의 크기를 바꿀 수 있게 할 때 쓰기 좋아요.
출처: 문서
본문
사용법 (Usage)
import { Splitter } from '@primereact/ui/splitter';
<Splitter.Root>
<Splitter.Panel />
<Splitter.Gutter>
<Splitter.Handle />
</Splitter.Gutter>
<Splitter.Panel />
</Splitter.Root>
예시 (Examples)
기본 (Basic)
드래그 가능한 구분선으로 레이아웃을 크기 조절 가능한 패널로 나눠요.
세로 (Vertical)
Splitter을 결합하면 고급 레이아웃을 만들 수 있어요.
크기 (Size)
패널의 초기 크기는 size 속성으로 퍼센트 기반으로 정의해요. 또한 minSize를 제공하면 크기 조절 중 최소값을 설정할 수 있어요.
최소/최대 크기 (Min Max Size)
Splitter 패널은 minSize와 maxSize 속성으로 정의된 범위 안에서 크기를 조절할 수 있어요.
접기 (Collapsible)
collapsedSize 속성으로 정의된 크기보다 작거나 같으면(minSize보다 작거나 같을 때) Splitter 패널을 접을 수 있어요.
중첩 (Nested)
Splitter을 결합하면 고급 레이아웃을 만들 수 있어요.
크기 조절 이벤트 (Resize Events)
Splitter은 크기 조절 과정에서 이벤트를 발생시킬 수 있어요. 패널이 크기 조절될 때 커스텀 로직을 처리하고 싶다면 활용하면 돼요.
상태 유지 (Stateful)
onResizeEnd 콜백으로 패널 크기를 영속화할 수 있어요. 이 예시는 크기를 localStorage에 저장해서 페이지를 다시 로드해도 복원되게 해요.
비활성화 (Disabled)
Splitter 패널을 비활성화해서 크기 조절을 막을 수 있어요. 루트에 disabled 속성을 설정하면 모든 패널에 적용되고, 특정 gutter에 disabled 속성을 설정하면 해당 gutter만 막을 수 있어요.
커스텀 (Custom)
Splitter은 다양한 스타일로 커스터마이즈할 수 있어요.
고급 (Advanced)
관련 문서 (Related)
서브 컴포넌트 (Sub-Components)
SplitterRoot, SplitterPanel, SplitterGutter, SplitterHandle 컴포넌트 문서는 Primitive API에서 확인하세요.
훅 (Hooks)
useSplitter 훅 문서는 Headless API에서 확인하세요.
접근성 (Accessibility)
WAI-ARIA 준수 세부사항과 키보드 지원은 Splitter Primitive에서 확인하세요.
테마 (Theming)
CSS 클래스 (CSS Classes)
styled 모드에서 사용하는 클래스 이름 목록이에요.
| ClassName | Description |
|---|---|
| p-splitter | Class name of the root element |
| p-splitterpanel | Class name of the panel element |
| p-splitter-gutter | Class name of the gutter element |
| p-splitter-gutter-handle | Class name of the handle element |
디자인 토큰 (Design Tokens)
디자인 토큰 목록이에요.
| Token | CSS Variable | Description |
|---|---|---|
| splitter.background | --p-splitter-background | Background of root |
| splitter.border.color | --p-splitter-border-color | Border color of root |
| splitter.color | --p-splitter-color | Color of root |
| splitter.transition.duration | --p-splitter-transition-duration | Transition duration of root |
| splitter.gutter.background | --p-splitter-gutter-background | Background of gutter |
| splitter.handle.size | --p-splitter-handle-size | Size of handle |
| splitter.handle.background | --p-splitter-handle-background | Background of handle |
| splitter.handle.border.radius | --p-splitter-handle-border-radius | Border radius of handle |
| splitter.handle.focus.ring.width | --p-splitter-handle-focus-ring-width | Focus ring width of handle |
| splitter.handle.focus.ring.style | --p-splitter-handle-focus-ring-style | Focus ring style of handle |
| splitter.handle.focus.ring.color | --p-splitter-handle-focus-ring-color | Focus ring color of handle |
| splitter.handle.focus.ring.offset | --p-splitter-handle-focus-ring-offset | Focus ring offset of handle |
| splitter.handle.focus.ring.shadow | --p-splitter-handle-focus-ring-shadow | Focus ring shadow of handle |
더 알아보기 (Learn more)
- Splitter 서브 컴포넌트의 세부 API를 Primitive 문서에서 살펴보세요.
onResizeEnd로 상태를 저장해 사용자 레이아웃을 기억하게 만들어 보세요.