Mosaic

A drag-and-drop grid for metric tiles. Users reposition tiles by dragging and resize them by dragging edge handles. Tile content adapts to its current size via a render prop.

Installation

npx dafink-ui add mosaic

Requires: @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities

Demo

Revenue
$48.5k
+12%
Active users
3,204+5.2%
Revenue over timeLast 8 months
Growth+24%

Composition

<Mosaic>
<MosaicTile />
</Mosaic>

Props

NameTypeDefaultDescription
layoutMosaicTileLayout[]-Required. Array of tile layout entries. Each entry has id, col, row, colSpan, and rowSpan. col and row are 1-based grid positions.
onLayoutChange(layout: MosaicTileLayout[]) => void-Required. Called when tiles are reordered or resized.
colsnumber12Number of grid columns.
rowHeightnumber160Base row height in pixels.
gapnumber16Gap between tiles in pixels.
minColSpannumber2Minimum column span a tile can shrink to.
minRowSpannumber1Minimum row span a tile can shrink to.
maxColSpannumbercolsMaximum column span. Defaults to the full grid width.
maxRowSpannumber4Maximum row span.