Splitter
영역을 여러 수평 또는 수직 측면으로 분할합니다.
사용 시기
Splitter 컴포넌트는 영역을 수평 또는 수직으로 분리하는 데 사용할 수 있습니다. 스플리터를 자유롭게 드래그하여 각 면의 크기를 조절할 수 있습니다.
기본
Panel 1
Panel 2
astro
---
import Splitter from '@/components/layout/Splitter.astro';
---
<Splitter class="border border-zinc-200 dark:border-zinc-800 rounded-lg h-64 shadow-sm bg-white dark:bg-zinc-900">
<div slot="panel-1" class="h-full w-full flex items-center justify-center">
<span class="text-zinc-500 font-medium text-center">Panel 1</span>
</div>
<div slot="panel-2" class="h-full w-full flex items-center justify-center">
<span class="text-zinc-500 font-medium text-center">Panel 2</span>
</div>
</Splitter> 수직
orientation="vertical" 속성을 설정하여 수직 레이아웃을 사용하면 패널을 수평으로 분할(수직으로 스택)할 수 있습니다. initialSplit 백분율을 설정할 수도 있습니다.
Header (30%)
Body (70%)
astro
---
import Splitter from '@/components/layout/Splitter.astro';
---
<Splitter orientation="vertical" initialSplit={30} class="border border-zinc-200 dark:border-zinc-800 rounded-lg h-64 shadow-sm bg-white dark:bg-zinc-900">
<div slot="panel-1" class="h-full w-full flex items-center justify-center bg-blue-50/50 dark:bg-blue-900/10">
<span class="text-blue-500 font-medium text-center">Header (30%)</span>
</div>
<div slot="panel-2" class="h-full w-full flex items-center justify-center bg-green-50/50 dark:bg-green-900/10">
<span class="text-green-500 font-medium text-center">Body (70%)</span>
</div>
</Splitter> 다중 패널
Splitter 컴포넌트를 서로 중첩하여 다중 패널을 가진 그리드 레이아웃을 만들 수 있습니다.
Sidebar
Editor
Terminal
astro
---
import Splitter from '@/components/layout/Splitter.astro';
---
<Splitter initialSplit={25} class="border border-zinc-200 dark:border-zinc-800 rounded-lg h-64 shadow-sm bg-white dark:bg-zinc-900">
<div slot="panel-1" class="h-full w-full flex items-center justify-center">
<span class="text-zinc-500 font-medium text-center">Sidebar</span>
</div>
<div slot="panel-2" class="h-full w-full">
<Splitter orientation="vertical" initialSplit={75}>
<div slot="panel-1" class="h-full w-full flex items-center justify-center">
<span class="text-zinc-500 font-medium text-center">Editor</span>
</div>
<div slot="panel-2" class="h-full w-full flex items-center justify-center">
<span class="text-zinc-500 font-medium text-center">Terminal</span>
</div>
</Splitter>
</div>
</Splitter> API
Splitter
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| class | 컨테이너의 추가 CSS 클래스. | string | - |
| orientation | 분할 방향 ("horizontal" 또는 "vertical"). | 'horizontal' | 'vertical' | 'horizontal' |
| initialSplit | 첫 번째 패널의 초기 분할 백분율. | number | 50 |