Skip to content

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
horizontal-default.svelte
<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
vertical.svelte
<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
handle-size.svelte
<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
controlled-size.svelte
<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

NameTypeDefaultDescription
direction"horizontal" | "vertical"'horizontal'Split axis - horizontal is side-by-side, vertical is stacked.
sizebindablenumber—Controlled size of the first pane in px (bindable).
defaultSizenumber250Initial size when uncontrolled.
minnumber100Minimum size of either pane in px.
maxnumber—Maximum size of the first pane in px.
onresize(size: number) => void—Called during drag with the current size.
handleSizenumber8Width/height of the drag handle in px.
classstring''Additional CSS classes on the container.
firstrequiredSnippet<[]>—Content for the first (left/top) pane.
secondrequiredSnippet<[]>—Content for the second (right/bottom) pane.

Usage tips

  • The first and second props 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:size for two-way binding to persist or display the pane size.
  • Set max to 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.

Documentation is licensed under CC BY 4.0. Phoundry names and marks remain reserved.