npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

reactive-layout

v1.0.2

Published

A Vue 3 layout engine for split-pane, tabbed interfaces with drag-and-drop — resizable splits, draggable tabs, and drop-to-split panels.

Readme

reactive-layout

npm version npm downloads license

A Vue 3 layout engine for building split-pane, tabbed interfaces with drag-and-drop. Think VS Code's panel system — resizable splits, draggable tabs, and drop-to-split — as a reusable package.

reactive-layout demo

Live Demo | npm | GitHub

Install

npm install reactive-layout

Vue 3 is a peer dependency.

Quick Start

<script setup>
import { provide } from "vue";
import { useLayout, SplitLayout } from "reactive-layout";
import MyPanelContent from "./MyPanelContent.vue";
import MyTabIcon from "./MyTabIcon.vue";

const { layout, moveTab, removeTab, splitPanel, updateSizesForSplit } = useLayout({
  defaultLayout: {
    type: "split",
    direction: "horizontal",
    sizes: [30, 70],
    children: [
      {
        type: "panel",
        id: "sidebar",
        tabs: [{ id: "files", panelType: "files", label: "Files" }],
        activeTabId: "files",
      },
      {
        type: "panel",
        id: "main",
        tabs: [{ id: "editor", panelType: "editor", label: "Editor" }],
        activeTabId: "editor",
      },
    ],
  },
  storageKey: "my-app-layout",
});

// Required by the layout components
provide("moveTab", moveTab);
provide("closeTab", (tabId) => removeTab(tabId));
provide("splitPanel", splitPanel);
provide("updateSizesForSplit", updateSizesForSplit);

// Your app-specific renderers
provide("layoutPanelContent", MyPanelContent);
provide("layoutTabIcon", MyTabIcon);
</script>

<template>
  <SplitLayout :node="layout" />
</template>

Concepts

The layout is a tree of two node types:

  • SplitNode — a container that arranges its children horizontally or vertically with resizable dividers
  • PanelNode — a leaf with a tab bar and content area
SplitNode (horizontal)
├── PanelNode "sidebar" [Files, Search]
└── SplitNode (vertical)
    ├── PanelNode "editor" [main.ts, utils.ts]
    └── PanelNode "terminal" [Terminal]

API

useLayout(options)

Creates and manages a reactive layout tree.

Options:

| Option | Type | Description | |---|---|---| | defaultLayout | SplitNode | The initial layout tree | | storageKey | string? | localStorage key for persistence. Omit to disable. |

Returns:

| Property | Description | |---|---| | layout | Ref<SplitNode> — the reactive layout tree, pass to <SplitLayout> | | moveTab(tabId, fromPanelId, toPanelId, insertIndex?) | Move or reorder a tab | | addTab(nearTabId, tab, activate?) | Add a tab to the panel containing nearTabId | | removeTab(tabId) | Remove a tab (cleans up empty panels) | | splitPanel(panelId, direction, tabId, position) | Split a panel by pulling a tab into a new pane | | updateSizesForSplit(split, newSizes) | Update pane sizes after a resize | | resetLayout() | Reset to defaultLayout and clear storage | | findPanelById(id) | Find a panel node by ID |

Components

<SplitLayout :node="layout" />

Recursively renders the layout tree. Renders LayoutPanel for leaf nodes and nested SplitLayout with ResizeHandle dividers for splits.

<LayoutPanel :panel="panelNode" />

Renders a tab bar with drag-and-drop support and a content area. Used internally by SplitLayout — you don't render this directly.

<ResizeHandle :direction="'horizontal' | 'vertical'" />

A draggable divider between split panes. Emits resize(delta) and resizeEnd events. Used internally by SplitLayout.

Provide/Inject

The layout components expect these injections:

Required (from useLayout)

| Key | Type | Description | |---|---|---| | moveTab | (tabId, fromPanelId, toPanelId, insertIndex?) => void | Tab move handler | | closeTab | (tabId) => void | Tab close handler | | splitPanel | (panelId, direction, tabId, position) => void | Panel split handler | | updateSizesForSplit | (split, newSizes) => void | Resize handler |

App-Specific Renderers

| Key | Type | Description | |---|---|---| | layoutPanelContent | Vue Component | Receives activeTab prop, renders the panel body | | layoutTabIcon | Vue Component | Receives tab prop, renders the tab icon |

Panel Content Component

Your content component receives the active tab and renders whatever your app needs:

<script setup>
import type { PanelTab } from "reactive-layout";

defineProps<{ activeTab: PanelTab }>();
</script>

<template>
  <FileExplorer v-if="activeTab.panelType === 'files'" />
  <CodeEditor v-else-if="activeTab.panelType === 'editor'" />
  <Terminal v-else-if="activeTab.panelType === 'terminal'" />
</template>

Tab Icon Component

<script setup>
import type { PanelTab } from "reactive-layout";

defineProps<{ tab: PanelTab }>();
</script>

<template>
  <span class="icon">{{ tab.panelType === 'files' ? '📁' : '📄' }}</span>
</template>

Types

interface PanelTab {
  id: string;
  panelType: string;
  label: string;
  closable?: boolean;
}

interface PanelNode {
  type: "panel";
  id: string;
  tabs: PanelTab[];
  activeTabId: string;
}

interface SplitNode {
  type: "split";
  direction: "horizontal" | "vertical";
  children: LayoutNode[];
  sizes: number[];  // percentages, must sum to 100
}

type LayoutNode = SplitNode | PanelNode;

Features

  • Recursive split panes (nest as deep as you want)
  • Drag tabs between panels or reorder within a panel
  • Drop on panel edges to split horizontally/vertical
  • Resizable panes with 5% minimum size
  • Optional localStorage persistence with debounced saves
  • SSR-safe (no window/localStorage access during server render)
  • Zero dependencies beyond Vue 3

CSS Variables

The components use CSS custom properties for theming:

| Variable | Default | Usage | |---|---|---| | --bg | #1e1e1e | Panel content background, active tab background | | --bg3 | #252526 | Tab bar background, inactive tab background | | --border | #333 | Borders, resize handle color | | --fg | #fff | Tab close button hover color | | --fg2 | #ccc | Active tab text, tab hover text |

License

MIT