Layout¶
golit.layout arranges the reactive view fragments into a page. References (View, Control, Controls) point at nodes by id; containers (Row, Stack, Grid, Tabs, Section, Sidebar) nest. Assign a tree to app.layout. See the Page layout tutorial.
Page-level layout — golit.layout.
By default Golit stacks every view vertically under one controls panel. A layout
lets you arrange the reactive view fragments into columns, tabs, a sidebar, etc.
Crucially, each view stays its own <section id=…>: the layout is just static
scaffold placed around the sections, so the POST out-of-band and SSE swaps still
target each view by id — moving a control re-renders only its fragment, wherever
it sits in the page.
from golit import layout as L
app.layout = L.Sidebar(
L.Controls(), # all inputs, in the sidebar
L.Stack(
L.Row(L.View("kpi"), L.View("status")),
L.Tabs({"Chart": L.View("chart"), "Data": L.View("table")}),
),
)
References (View/Control) point at nodes by id; containers (Row,
Stack, Grid, Tabs, Section, Sidebar, Controls) nest. A
plain string child is passed through as trusted HTML, so golit.ui components
drop in as static decoration.
View
¶
Control
¶
Controls
¶
A panel of input controls — the given ids, or every input if none given.
columns fixes the grid column count; by default it flows with the viewport,
or collapses to a single column inside a :class:Sidebar.
Source code in python/golit/layout.py
Row
¶
A responsive row. widths (summing to 12) gives a custom split.
Source code in python/golit/layout.py
Stack
¶
Grid
¶
A fixed-column responsive grid.
Source code in python/golit/layout.py
Tabs
¶
A tab group; panels maps label → child.
Source code in python/golit/layout.py
Section
¶
A titled card grouping its children.
Source code in python/golit/layout.py
Sidebar
¶
A sidebar + main two-column split. width is the sidebar span (of 12).
Source code in python/golit/layout.py
validate_layout
¶
Check every View/Control reference points at a real view/input and
appears at most once — each is a unique swap target, so a duplicate would put
two elements with the same id in the DOM and break the by-id swap.