Svelte Dock Layout

A docking layout is the shape every serious internal tool converges on: panes you can drag, split, stack as tabs and resize, arranged however the person using it prefers. SvDockLayout gives you that, and the whole arrangement is a plain serializable tree you can store per user.

Because the layout is data, restoring a workspace is assigning a value, and shipping a sensible default layout is writing one down. SvDockManager adds floating and popped-out windows on top for the cases where a pane needs to leave the page entirely.

Install

npm i @svgrid/grid

Free and MIT-licensed in @svgrid/grid: no license key, no row cap, no watermark.

The code

<script lang="ts">
  import { SvDockLayout, dockGroup, dockTabs, dockPane, type DockNode } from '@svgrid/grid'

  let layout = $state<DockNode>(
    dockGroup('row', [
      dockTabs([dockPane('explorer', 'Explorer')]),
      dockGroup('column', [
        dockTabs([dockPane('editor', 'index.ts'), dockPane('readme', 'README.md')]),
        dockTabs([dockPane('terminal', 'Terminal')]),
      ], [0.7, 0.3]),
    ], [0.25, 0.75]),
  )
</script>

<SvDockLayout bind:layout>
  {#snippet pane(p)}
    {#if p.id === 'explorer'}<FileTree />{:else}<div>{p.title}</div>{/if}
  {/snippet}
</SvDockLayout>

What you get

Live examples

Documentation

Related articles

Frequently asked questions

How do I build a dockable layout in Svelte?

Compose a DockNode tree with dockGroup, dockTabs and dockPane, bind it to SvDockLayout, and render each pane from the pane snippet by its id.

Can I save and restore the layout?

Yes. The bound layout is a plain serializable object, so JSON.stringify it into localStorage or a user profile and assign it back on load.

Can a pane open in its own window?

Yes. SvDockManager supports popping a pane out into a real browser window, which stays connected to the same application state.

Is the dock layout free?

Yes. The docking layout and the dock manager are MIT-licensed in @svgrid/grid.

Build something else

Get started · Browse the gallery · Pricing