Skip to content

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.

Define the tile array outside the component so its identity remains stable between renders:

Dashboard.tsx
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.

Mosyn fills its parent; it does not create an intrinsic height. Add a definite height chain from the document root to the grid host:

dashboard.css
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;
}

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.

Buttons, inputs, and other controls inside a tile should not begin a drag. Pass selectors through DragCancel:

Dashboard.tsx
<Mosyn
tiles={tiles}
DragCancel={['button', 'input', 'textarea', 'select', '.no-drag']}
/>

Mosyn checks the pointer target against these selectors before starting the drag threshold.

With the dashboard running:

  1. Drag a tile into empty space to reposition it.
  2. Drop near another tile’s edge to split the available region.
  3. Drop over its center to exchange positions.
  4. 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.