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 |