Skip to content

UI Layout Catalog

A breadth-first survey of UI layout libraries and the layout subsystems embedded in major UI/TUI/GUI frameworks. This catalog complements the TUI Libraries Catalog by zooming in on the layout dimension specifically: how widgets get sizes and positions, what primitives are exposed to the developer, and what algorithm runs underneath.

The scope is deliberately broad. We cover renderer-agnostic layout libraries (Clay, Yoga, Taffy), web platform layout specifications (CSS Flexbox, CSS Grid, Normal Flow), modern declarative GUI frameworks (SwiftUI, Jetpack Compose, Flutter), traditional desktop GUI layouts (WPF/XAML, Qt, GTK), JVM and Apple stacks (Swing/MiG, Auto Layout), Android (ConstraintLayout), classical Tk geometry managers, immediate-mode UI layout (Dear ImGui, egui), tiling window managers (i3/sway, xmonad), and the foundational typesetting algorithm of Knuth-Plass. Each entry has its own detailed write-up.

Renderer-agnostic layout libraries

LibraryLanguageLayout ModelSizing VocabularyStatusLinks
ClayCBox-flow (row/column)FIT / GROW / FIXED / PERCENT + min/maxActiverepo
YogaC++Flexbox (CSS subset)flex-grow / flex-shrink / flex-basisActiverepo / docs
TaffyRustFlexbox + CSS Grid + CSS BlockCSS Length / Percent / Auto / Fr / etc.Activerepo
StretchRustFlexbox (CSS subset)flex-grow / flex-shrink / flex-basisArchivedrepo
KiwiC++ / PyLinear constraint solverVariable + Constraint + StrengthActiverepo

Foundational algorithms

AlgorithmDomainYearReference ImplementationsLinks
CassowaryLinear constraints1997Apple Auto Layout, GTK 4, kiwisolver, Cassowary.js, Cassowary.pypaper
Knuth-PlassLine breaking1981TeX, LuaTeX, SILE, knuth-plass.js, several CSS engine experimentspaper

Web platform layout specs

SpecificationLevel / YearBrowsers InteropNon-browser Implementations
CSS Normal FlowCSS 2.1 (2011) / Display 3UniversalFoundational; every other CSS layout mode is a deviation from it
CSS FlexboxLevel 1 (2017) / Level 2UniversalYoga, Taffy, Stretch, Ink, Textual
CSS GridLevel 1 (2017) / Level 2UniversalTaffy; rare in TUI libraries

Modern declarative GUI framework layouts

FrameworkLanguageLayout ProtocolSizing VocabularyCross-link
SwiftUISwiftPropose-and-respondmin / ideal / max preferred sizesApple-only
Jetpack ComposeKotlinMeasure / placeConstraints(minWidth, maxWidth, ...)Mosaic ports the runtime to terminals
FlutterDartConstraints down, sizes upBoxConstraints (tight / loose)-

Traditional desktop GUI layouts

FrameworkLanguageLayout ModelSizing VocabularyNotable lineage
WPF / XAML.NET (XAML+C#)Two-pass Measure / ArrangeAuto / Star (*) / pixel + alignmentInherited by Silverlight, UWP, .NET MAUI, Avalonia, Uno
Qt LayoutsC++ / QMLBox / Grid / Form / StackedQSizePolicy + stretch factorQHBoxLayout / QVBoxLayout / QGridLayout / QFormLayout
GTK 4C (with bindings)Pluggable GtkLayoutManagerhalign / valign + hexpand / vexpandGtkBoxLayout, GtkGridLayout, GtkConstraintLayout (Cassowary)
Swing / MiG LayoutJavaLayoutManager interfacepreferred / min / max + per-manager constraintsFlowLayout, BorderLayout, GridLayout, BoxLayout, GridBagLayout, GroupLayout, MiG
Tk geometry managersTcl/Tkpack / grid / place-side, -fill, -expand (pack); -sticky, -weight (grid)Originated 1990; predates most modern layout APIs

Apple / Android constraint-based

SystemPlatformSolverAdoption
Auto LayoutUIKit / AppKitCassowarymacOS 10.7 (2011), iOS 6 (2012), still the substrate of UIKit
Android ConstraintLayoutAndroid ViewsCassowary-derivativeAndroid Studio default for new layouts since 2017

Immediate-mode layout

LibraryLanguageLayout StyleCompanion TUI Port
Dear ImGuiC++Cursor-based + Tables APIImTui
eguiRustCursor-based with retained sizing-

Tiling and structural layout

SystemAlgorithmConfiguration
i3 / swayBinary split-container treePlain text config + IPC
xmonadFunctional layout combinators (typeclass)Haskell

TUI layout models (cross-references)

These libraries are documented in the TUI Libraries Catalog; this section pulls out their layout subsystem for direct comparison with the dedicated layout libraries above.

LibraryLayout ApproachSizing Vocabulary
Ratatui (Rust)Constraint solver on RectsLength(n) / Percentage(p) / Ratio(a, b) / Min(n) / Max(n) / Fill(n)
Textual (Python)CSS subset (Flexbox-like + Grid)CSS keywords (auto, 1fr, 100%, fixed) plus dock
Ink (JavaScript)Yoga (Flexbox)Yoga flex-grow / flex-basis etc. - see Yoga
FTXUI (C++)Functional combinators (hbox, vbox, gridbox)size(WIDTH, EQUAL, n) decorators
Brick (Haskell)Pure-functional combinatorspadLeftRight, hLimit, vLimit, padded, border
tview (Go)Flex with proportionsFixed size + proportional weight
Cursive (Rust)LinearLayout / nested viewsMin size with caller-controlled bounds
Notcurses (C)Planes (absolute positioning) + helpersManual rectangle math
Mosaic (Kotlin)Jetpack Compose runtime on terminalSee Jetpack Compose
Nottui (OCaml)Functional reactive layoutBox combinators with stretch
libvaxis (Zig)ImperativeManual
ImTui (C++)Dear ImGui on terminalSee Dear ImGui
snacks.nvim (Lua)Floating windows on Neovim's window/buffer modelWindow-row/col grid + size hints
broot (Rust)Custom (built on Ratatui)-

Architectural Taxonomy

By Sizing Vocabulary

VocabularyDescriptionLibraries
Fit / Grow / Fixed / PercentSmall primitives with optional min/max clamps; siblings with GROW share equallyClay
Flex-grow / shrink / basisCSS Flexbox sibling weighting along main axisYoga, CSS Flexbox, Taffy, Stretch, Ink
Linear constraints (Cassowary)Variables linked by =, <=, >= with strength prioritiesCassowary, Kiwi, Auto Layout, Android ConstraintLayout, GTK 4 ConstraintLayout
Grid template (fr, minmax)Track-based two-axis grid with named lines / areasCSS Grid, Taffy, WPF Grid (* star sizing close cousin)
Star sizingProportional sibling weights (*, 2*)WPF / XAML, Qt (stretch factor)
Per-side stickiness / fillAnchor to one or more edges of a cellTk (grid -sticky nsew), GridBagLayout (anchor / fill)
Tight / loose constraintsConstraints flow down, sizes flow up; each box answers a (minW, maxW, minH, maxH)Flutter, Compose
Propose-and-respondParent proposes an optional (width?, height?); child returns a CGSizeSwiftUI
Cursor + auto-advanceLayout cursor moves after each widget; explicit SameLine for horizontal flowDear ImGui, egui, ImTui
Tiling treeBinary split tree; new windows insert as siblings; resize via proportionsi3 / sway, xmonad
Optimal line breakingDynamic programming over breakpoints with glue / penalty modelKnuth-Plass

By Measure / Arrange Protocol

ProtocolDescriptionLibraries
Single-pass top-downParent passes constraints; child reports size; no second passFlutter, Compose
Two-pass Measure / ArrangePhase 1 collects desired sizes bottom-up; phase 2 distributes space top-downWPF / XAML, GTK 4, Qt, Swing, SwiftUI (effectively)
Iterative solverConstraint solver runs to a stable solutionCassowary, Kiwi, Auto Layout, Android ConstraintLayout
Immediate / cursor-basedNo measure pass; widgets are placed in order they are issuedDear ImGui, egui
Combinator algebraLayout is a pure function from Rectangle to placementsxmonad, Brick, Nottui, FTXUI
Render-command emissionLayout pass produces a list of draw commands; renderer agnosticClay

By Embedding

EmbeddingDefinitionExamples
Standalone layout libraryJust sizing and positioning; renderer is the application's responsibilityClay, Yoga, Taffy, Stretch, Kiwi
Spec without bundled implementationDefinition of behavior; many engines implement itCSS Flexbox, CSS Grid, CSS Normal Flow, Cassowary, Knuth-Plass
Baked into a GUI frameworkLayout types are part of a larger widget systemSwiftUI, Compose, Flutter, WPF, Qt, GTK 4, Swing, Auto Layout
Baked into a window manager / WM-like toolLayout is the product; UI affordances are minimali3 / sway, xmonad
Embedded as a TUI sublayerThe layout primitives are wired through a terminal rendererAll TUI libraries

Detailed Studies

The following entries are analysed in depth.

Pure layout libraries

  • Clay - single-header C library; sizing primitives FIT / GROW / FIXED / PERCENT; render-command emission
  • Yoga - Meta's cross-platform Flexbox; the engine behind Ink and React Native
  • Taffy - Rust; supports CSS Flexbox + Grid + Block; used by Dioxus, Bevy, Zed
  • Stretch - Taffy's archived Flexbox-only predecessor
  • Kiwi - C++ Cassowary implementation; the engine in kiwisolver, Matplotlib's constrained_layout, enaml

Foundational algorithms

  • Cassowary - linear arithmetic constraint solver (Badros & Borning, 1997); the substrate of iOS Auto Layout
  • Knuth-Plass - optimal line breaking via dynamic programming (1981); the algorithm in TeX, SILE, and (selectively) modern browsers

Web platform layout specs

  • CSS Normal Flow - block / inline formatting contexts, the box model, margin collapsing, floats, position
  • CSS Flexbox - one-axis flex container; main / cross axes; the spec that birthed Yoga
  • CSS Grid - two-axis grid with tracks, lines, areas, subgrid, fr unit, minmax, auto-fill / auto-fit

Modern declarative GUI framework layouts

  • SwiftUI - HStack / VStack / ZStack / Grid; propose-and-respond protocol; Layout protocol for custom layouts (iOS 16+)
  • Jetpack Compose - Row / Column / Box / ConstraintLayout; measure-and-place protocol; Modifier.layout; intrinsic measurements
  • Flutter - Row / Column / Stack / Wrap / Flex; constraints-down-sizes-up; RenderBox protocol

Traditional desktop GUI layouts

  • WPF / XAML - Grid (with * star sizing) / StackPanel / DockPanel / WrapPanel / Canvas; Measure / Arrange protocol; inherited by Avalonia, UWP, MAUI
  • Qt Layouts - QHBoxLayout / QVBoxLayout / QGridLayout / QFormLayout / QStackedLayout; QSizePolicy + stretch factor; QML alternatives
  • GTK 4 - pluggable GtkLayoutManager; GtkBoxLayout, GtkGridLayout, GtkConstraintLayout (Cassowary), GtkOverlayLayout
  • Swing / MiG Layout - AWT LayoutManager family; the GridBagLayout case study; GroupLayout; MiG's declarative constraint strings
  • Tk geometry managers - pack (1990), grid (1996), place; the classical layout API that influenced AWT and many others

Apple / Android constraint-based

  • Auto Layout - Cassowary in production; NSLayoutConstraint, anchors, intrinsic content size, content hugging / compression resistance
  • Android ConstraintLayout - flat hierarchy with anchored constraints, guidelines, barriers, chains; the modern Android default

Immediate-mode layout

  • Dear ImGui - cursor-based layout; Columns (legacy) and Tables API (since 1.80)
  • egui - Rust immediate mode with retained sizing memory; horizontal / vertical / columns

Tiling and structural layout

  • i3 / sway - binary split-container tree; configurable in plain text; the canonical modern tiling WM
  • xmonad - layouts as typeclass values composed with |||; pure-Haskell window arrangement

Comparative

A focused cross-library comparison is in the TUI Libraries Comparison. A follow-up comparison.md for layout libraries specifically may be added here as the catalog matures.


References