Skip to content

Latest commit

聽

History

History

core

README.md

@dynamix-layout/core

The framework-agnostic engine behind Dynamix Layout. It handles the layout tree (rows, tabsets and tabs), geometry and minimum sizes, splitters, drag-and-drop targets, maximize and fold, and versioned serialization. It has no dependencies, no global state and no DOM access. Every createLayout() is an independent instance.

Use it directly to build an adapter for another framework, or through @dynamix-layout/react or @dynamix-layout/solid.

Install

npm install @dynamix-layout/core

Quick start

import { createLayout } from '@dynamix-layout/core'

const layout = createLayout({
	tabs: [{ id: 'editor' }, { id: 'terminal' }, { id: 'preview' }],
	onLayoutChange: (json) => localStorage.setItem('layout', JSON.stringify(json)),
})

layout.subscribe((snapshot) => {
	for (const [id, rect] of snapshot.rects.tabsets) draw(id, rect)
})
layout.setContainerRect({ x: 0, y: 0, width: 1200, height: 800 })
layout.moveTab('terminal', { type: 'root', position: 'bottom' })

Documentation

MIT 漏 Akash Aman