Getting started
This guide builds the smallest complete Mosyn dashboard: a sized host, a shared manager, and two draggable tiles.
If the package is not installed yet, follow Installation first.
Create the dashboard
Section titled “Create the dashboard”Define the tile array outside the component so its identity remains stable between renders:
import { Mosyn, MosynManager } from 'mosyn';import type { Tile } from 'mosyn';import 'mosyn/style.css';import './dashboard.css';
const tiles: Tile[] = [ { id: 'overview', x: 1, y: 1, w: 58, h: 18, renderer: <section className="panel">Overview</section>, }, { id: 'activity', x: 61, y: 1, w: 58, h: 18, renderer: <section className="panel">Activity</section>, },];
export function Dashboard() { return ( <main className="dashboard"> <MosynManager> <Mosyn tiles={tiles} /> </MosynManager> </main> );}One MosynManager can serve every grid in your dashboard. Keep nested grids under the same manager so tiles can move between them without remounting.
Give the grid a real height
Section titled “Give the grid a real height”Mosyn fills its parent; it does not create an intrinsic height. Add a definite height chain from the document root to the grid host:
html,body,#root { height: 100%; margin: 0;}
.dashboard { display: flex; min-height: 0; height: 100%;}
.panel { width: 100%; height: 100%; padding: 1rem; background: #e2f8f0; color: #123b36;}Understand the coordinates
Section titled “Understand the coordinates”Tile geometry uses grid units, not pixels:
| Field | Meaning |
|---|---|
x, y |
Top-left position |
w, h |
Width and height span |
The root grid contains 120 columns, and each row is 12 pixels tall. The example uses two 58-column tiles separated by a two-unit gutter.
Keep controls interactive
Section titled “Keep controls interactive”Buttons, inputs, and other controls inside a tile should not begin a drag. Pass selectors through DragCancel:
<Mosyn tiles={tiles} DragCancel={['button', 'input', 'textarea', 'select', '.no-drag']}/>Mosyn checks the pointer target against these selectors before starting the drag threshold.
What to try
Section titled “What to try”With the dashboard running:
- Drag a tile into empty space to reposition it.
- Drop near another tile’s edge to split the available region.
- Drop over its center to exchange positions.
- Select a tile and use its resize handles.
The layout now has the minimum foundation required for nested grids, state subscriptions, and custom tile renderers.