Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Layout

manywidgets ships three layout primitives that arrange other widgets while keeping them fully interactive and linked — live and in a static export with no kernel:

  • Row — children left-to-right (a flex row; wraps if it runs out of room).

  • Column — children top-to-bottom (a flex column).

  • Grid — children flowed row-major into columns equal columns.

They share two ideas:

  • gap sets the space between children on every primitive. Row/Column also take align — the cross-axis align-items (vertical for Row, horizontal for Column); Grid takes columns.

  • They compose. Any layout can hold any widget, including another layout, so you build a whole screen by nesting Row/Column/Grid.

Pass children positionally (Row(a, b)) or as a list (Row(children=[a, b])). Linking works as usual (see the linking guide) — a control and what it drives can sit side by side.

Row

Children sit left-to-right and wrap to the next line if they run out of room. gap sets the spacing; align lines up children of different heights along the cross (vertical) axis.

Column

The vertical sibling of Row — children stack top-to-bottom. Here a Slider drives a NumberDisplay stacked beneath it.

Grid

columns equal columns; children flow row-major (left-to-right, top-to-bottom). A grid of Stat cards makes a compact dashboard.

Nesting

Layouts are widgets too, so they nest — a Row can hold Columns, a Column can hold a Grid, and so on. That’s how the three primitives build up a whole screen. Here a Row places two control groups side by side, each a Column that pairs a slider with its live readout.

A linked dashboard

A bigger, real nesting: a header on top, a Column of controls beside a Chart, and a Grid of summary cards below — the whole thing is one outer Column (Column → Row → Column + Chart, then a Grid). The controls drive the chart live (and statically) — switch its type, toggle the legend, or change its height.

Controls beside a map

The same primitives wrap a lonboard map. One thing to know: a plain flex Row sizes each child to its content, but a map fills its container and has no intrinsic width — in a Row it would collapse to nothing. A two-column Grid gives the controls and the map each a defined column, so the map gets real width. (Install with pip install "manywidgets[lonboard]"; see the lonboard guide.)