Splitter
Splits the area into multiple horizontal or vertical sides.
When To Use
The Splitter component can be used to separate areas horizontally or vertically. You can freely drag the splitter to adjust the size of each side.
Basic
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> Vertical
Use vertical layout by setting orientation="vertical" prop to split panels horizontally (stacking them vertically). You can also set the initialSplit percentage.
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> Multiple Panels
You can nest Splitter components inside each other to create multiple panels grid layouts.
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
| Property | Description | Type | Default |
|---|---|---|---|
| class | Additional CSS classes for the container. | string | - |
| orientation | The split orientation ("horizontal" or "vertical"). | 'horizontal' | 'vertical' | 'horizontal' |
| initialSplit | Initial percentage split for the first panel. | number | 50 |