Phoundry UI

SplitPane Experimental

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)

Sidebar
Main content area
Show code
<SplitPane defaultSize={200}>
  {#snippet first()}
    <div class="p-4">Sidebar</div>
  {/snippet}
  {#snippet second()}
    <div class="p-4">Main content</div>
  {/snippet}
</SplitPane>

Vertical

Top pane
Bottom pane
Show code
<SplitPane direction="vertical" defaultSize={150}>
  {#snippet first()}
    <div class="p-4">Top pane</div>
  {/snippet}
  {#snippet second()}
    <div class="p-4">Bottom pane</div>
  {/snippet}
</SplitPane>

Handle size

Increase handleSize for touch-heavy layouts-. The hit target grows while the visible groove stays styled.

Wide handle
Drag the padded divider
Show code
<SplitPane handleSize={16} defaultSize={200}>...</SplitPane>

Controlled Size

Width: 200px
Drag the handle to resize
Show code
<SplitPane bind:size={panelSize} min={80} max={400}>
  {#snippet first()}
    <div class="p-4">Width: {panelSize}px</div>
  {/snippet}
  {#snippet second()}
    <div class="p-4">Main</div>
  {/snippet}
</SplitPane>

Props

PropTypeDefaultDescription
direction 'horizontal' | 'vertical''horizontal'Split axis - horizontal is side-by-side, vertical is stacked.
size number-Controlled size of the first pane in px (bindable).
defaultSize number250Initial size when uncontrolled.
min number100Minimum 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 number8Width/height of the drag handle in px.
class string-Additional CSS classes on the container.
first requiredSnippet-Content for the first (left/top) pane.
second requiredSnippet-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.