SplitPane
Resizable split layout with a draggable divider. Supports horizontal (side-by-side) and vertical (stacked) directions with configurable min/max size constraints.
import { SplitPane } from "phoundry-ui";Horizontal (default)
Loading interactive example…
View source
<script lang="ts"> import { SplitPane } from "phoundry-ui";</script>
<div class="h-48 overflow-hidden rounded-lg border border-border-muted"> <SplitPane defaultSize={200} class="h-full"> {#snippet first()} <div class="h-full bg-surface-sunken p-3 text-xs text-txt-secondary"> Sidebar </div> {/snippet} {#snippet second()} <div class="h-full p-3 text-xs text-txt-secondary">Main content area</div> {/snippet} </SplitPane></div>Vertical
Loading interactive example…
View source
<script lang="ts"> import { SplitPane } from "phoundry-ui";</script>
<div class="h-64 overflow-hidden rounded-lg border border-border-muted"> <SplitPane direction="vertical" defaultSize={150} class="h-full"> {#snippet first()} <div class="h-full bg-surface-sunken p-3 text-xs text-txt-secondary"> Top pane </div> {/snippet} {#snippet second()} <div class="h-full p-3 text-xs text-txt-secondary">Bottom pane</div> {/snippet} </SplitPane></div>Handle size
Loading interactive example…
View source
<script lang="ts"> import { SplitPane } from "phoundry-ui";
let fatHandleSize = $state(220);</script>
<p class="mb-2 text-xs text-txt-secondary"> Increase <code>handleSize</code> for touch-heavy layouts-. The hit target grows while the visible groove stays styled.</p><div class="h-48 overflow-hidden rounded-lg border border-border-muted"> <SplitPane bind:size={fatHandleSize} handleSize={18} min={80} max={420} class="h-full" > {#snippet first()} <div class="h-full bg-surface-sunken p-3 text-xs text-txt-secondary"> Wide handle </div> {/snippet} {#snippet second()} <div class="h-full p-3 text-xs text-txt-secondary"> Drag the padded divider </div> {/snippet} </SplitPane></div>Controlled Size
Loading interactive example…
View source
<script lang="ts"> import { SplitPane } from "phoundry-ui";
let horizontalSize = $state(200);</script>
<div class="h-48 overflow-hidden rounded-lg border border-border-muted"> <SplitPane bind:size={horizontalSize} min={80} max={400} class="h-full"> {#snippet first()} <div class="h-full bg-surface-sunken p-3 text-xs text-txt-secondary"> Width: {horizontalSize}px </div> {/snippet} {#snippet second()} <div class="h-full p-3 text-xs text-txt-secondary"> Drag the handle to resize </div> {/snippet} </SplitPane></div>API
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
direction | "horizontal" | "vertical" | 'horizontal' | Split axis - horizontal is side-by-side, vertical is stacked. |
sizebindable | number | — | Controlled size of the first pane in px (bindable). |
defaultSize | number | 250 | Initial size when uncontrolled. |
min | number | 100 | Minimum size of either pane in px. |
max | number | — | Maximum size of the first pane in px. |
onresize | (size: number) => void | — | Called during drag with the current size. |
handleSize | number | 8 | Width/height of the drag handle in px. |
class | string | '' | Additional CSS classes on the container. |
firstrequired | Snippet<[]> | — | Content for the first (left/top) pane. |
secondrequired | Snippet<[]> | — | Content for the second (right/bottom) pane. |
Usage tips
- The
firstandsecondprops are Svelte snippets - use{#snippet first()}...{/snippet}syntax. - The container must have a defined height (e.g.
h-full,h-screen) for the split to render correctly. - Use
bind:sizefor two-way binding to persist or display the pane size. - Set
maxto prevent the first pane from consuming the entire container.
CSS styling
.ph-split-pane is the stable identification hook for SplitPane. Part selectors and --_ph-* properties are internal. Component CSS is scoped and unlayered; Consumer classes remain additive and utility overrides may lose precedence.
size, defaultSize, min, max, and handleSize retain their pixel-based measurement contract. Direction and drag state are semantic attributes; fixed divider styling lives in CSS.
Keep the shared component stylesheet and a named Theme imported. Decorative motion respects reduced-motion preferences.