Overview
TheBox widget is a flexible container that supports flexbox layout properties. It’s the primary building block for creating complex layouts in Kraken TUI.
Constructor
BoxOptions
Width of the box. Accepts:
- Number: fixed width in cells
- String: percentage (e.g., “50%”) or “auto”
Height of the box. Accepts:
- Number: fixed height in cells
- String: percentage (e.g., “100%”) or “auto”
Flex layout direction. Valid values:
"row"- horizontal layout (default)"column"- vertical layout"row-reverse"- horizontal, reversed"column-reverse"- vertical, reversed
Main axis alignment. Valid values:
"flex-start"- align to start (default)"flex-end"- align to end"center"- center alignment"space-between"- space between items"space-around"- space around items"space-evenly"- even spacing
Cross axis alignment. Valid values:
"stretch"- stretch to fill (default)"flex-start"- align to start"flex-end"- align to end"center"- center alignment
Spacing between child elements in cells. Applies to both row and column gaps.
Inner padding. Accepts:
- Single number: applies to all sides
- Array:
[top, right, bottom, left]
Border style. Valid values:
"none"- no border (default)"single"- single-line border"double"- double-line border"rounded"- rounded corners"bold"- bold border
Foreground (text) color. Accepts:
- Hex string:
"#FF0000" - Color name:
"red","blue", etc. - 256-color code:
196
Background color. Same format as
fg.Example
Inherited Methods
Box inherits all methods from the Widget base class, including:append(child)- Add child widgetsremoveChild(child)- Remove child widgetssetVisible(visible)- Control visibilitydestroy()- Clean up resourcesanimate(options)- Animate properties
Notes
- Box is the primary container widget for building layouts
- Supports full flexbox layout model (direction, justify, align, gap)
- Can nest boxes infinitely for complex layouts
- All style properties can be set via constructor options or inherited Widget methods
- Flexbox properties follow CSS Flexbox conventions