class RatatuiRuby::Layout
Divides an area into smaller chunks.
Terminal screens vary in size. Hardcoded positions break when the window resizes. You need a way to organize space dynamically.
This class manages geometry. It splits a given area into multiple sections based on a list of constraints.
Use layouts to build responsive grids. Stack sections vertically for a sidebar-main structure. Partition them horizontally for headers and footers. Let the layout engine do the math.
Examples
# A simple vertical split (Sidebar / Main) Layout.new( direction: :horizontal, constraints: [ Constraint.length(20), # Sidebar Constraint.min(0) # Main content ] ) # Flex layout (Centering a block) Layout.new( direction: :vertical, flex: :center, constraints: [Constraint.length(10)], # A 10-row block centered vertically children: [modal_block] )
Attributes
Widgets to render in each section (optional).
If provided, ‘children` is rendered into the area defined by `constraints`.
Array of rules defining section sizes.
Direction of the split.
Either :vertical (top to bottom) or :horizontal (left to right).
layout.direction # => :vertical
Strategy for distributing extra space.
One of :legacy, :start, :center, :end, :space_between, :space_around.