Installation
Install the React or the Vue package, each of which re-exports the whole core, or the framework-free core alone for Node, tests or another framework.
The React package is the only one a React app installs: it re-exports everything the core exports, so the model, the types and the pure rules come from the same import.
pnpm add @fragiola/splitter-reactIt needs react and react-dom 19 as peers. Nothing else: the package has no runtime
dependency of its own and ships no stylesheet to import.
Importing
import { createSplitterModel, Splitter, type SplitterJson } from "@fragiola/splitter-react";Splitter is the namespace of the primitives (Splitter.Group, Splitter.Panel,
Splitter.Separator); the hooks (useSplitter, useSplitterRef, usePanel, ...) are named
exports beside it. The components are client components: in a framework with server components,
render them from a file that starts with "use client". They still render on the server (see
Server rendering).
The core alone
@fragiola/splitter is the framework-free core: the model, its commands, the JSON document and
its schema, the layout rules and the engine. It runs in plain Node with no DOM, which is what you
want for a server that validates saved layouts or an assistant that drives one.
pnpm add @fragiola/splitterimport { createSplitterModel, type SplitterJson, validateSplitter } from "@fragiola/splitter";
/** A model of the saved layout, or of the defaults when the document is not valid. */
export function loadLayout(json: unknown) {
const valid = validateSplitter(json).length === 0;
return createSplitterModel(valid ? (json as SplitterJson) : undefined);
}Both packages are ES modules with their types included.
Introduction
What the package does for a split view (resizing, the keyboard, collapsing, a saved layout) and what stays yours, down to every pixel, cursor and word.
Your first split view
Build a group of panels with separators between them, give the panels sizes, stack them vertically, and read the layout as it changes.