Skip to content

Nested grids

Use a nested grid when a dashboard area needs its own local arrangement: a project workspace, a grouped report, or a drill-down panel.

A container tile owns its child tiles. Set isContainer to true, provide children, and render a second <Mosyn /> from its renderer.

workspace.tsx
import { Mosyn } from 'mosyn';
import type { Tile } from 'mosyn';
const workspaceTiles: Tile[] = [
{ id: 'notes', parentId: 'workspace', x: 1, y: 1, w: 24, h: 14, renderer: <Notes /> },
{ id: 'tasks', parentId: 'workspace', x: 27, y: 1, w: 24, h: 14, renderer: <Tasks /> },
];
export const workspace: Tile = {
id: 'workspace',
x: 1,
y: 21,
w: 78,
h: 40,
isContainer: true,
children: workspaceTiles,
renderer: (tile) => <Mosyn tiles={tile.children ?? []} container={tile} />,
};

The container prop identifies the nested grid and gives it the dimensions of its parent tile. The nested grid is displayed by your renderer; Mosyn does not generate that application UI for you.

Place the root grid and every nested grid inside the same MosynManager.

Dashboard.tsx
import { Mosyn, MosynManager } from 'mosyn';
export function Dashboard() {
return (
<MosynManager>
<Mosyn tiles={[workspace]} />
</MosynManager>
);
}

Do not add a second provider around the child grid. A shared provider is what lets Mosyn coordinate the complete workspace.

Give every tile a unique id, including tiles in different nested grids. The id is the identity Mosyn uses to track content and movement.

workspace.tsx
const workspaceTiles: Tile[] = [
{ id: 'workspace-notes', parentId: 'workspace', x: 1, y: 1, w: 24, h: 14, renderer: <Notes /> },
{ id: 'workspace-tasks', parentId: 'workspace', x: 27, y: 1, w: 24, h: 14, renderer: <Tasks /> },
];

Treat the container renderer as current state

Section titled “Treat the container renderer as current state”

Use the tile argument passed to renderer. It carries the current children collection for that container.

workspace.tsx
renderer: (tile) => <Mosyn tiles={tile.children ?? []} container={tile} />

Avoid closing over the original workspaceTiles array in the renderer. The current tile is the source Mosyn updates as the nested workspace changes.