box (cellium v0.1.0)
View SourceBox widget module for rendering rectangular containers with borders.
This module provides a container widget that draws a border around its contents. The box can contain child widgets and renders with different border styles depending on focus state.
Usage
Basic box as a container:
{box, [{id, my_box}, {size, 10}, {color, yellow}], [
{text_input, [{id, input1}, {expand, true}]}
]}Empty decorative box:
box:new(decorative_box, 20, 5)Properties
width(integer): Width of the box in characters. Set by layout when used as a containerheight(integer): Height of the box in characters. Set by layout when used as a containerorientation(atom): Layout orientation for children. Default: verticalpadding(map): Inner padding. Default: 1 on all sidestype: Set tocontainer(can hold child widgets)color(atom): Border color
Border Styles
- Unfocused: Square/single-line border (
┌─┐│└┘) - Focused or child has focus: Double-line border (
╔═╗║╚╝)
Container Behavior
The box is a container widget, so:
- It can have children specified in the DSL
- The layout system calculates dimensions for children
- Default padding of 1 character on all sides
- Children are laid out vertically by default
Example
{box, [{id, input_box}, {size, 5}, {color, cyan}], [
{text_input, [{id, ti1}, {wrap, true}, {expand, true}]}
]}
Summary
Functions
Creates a new box with default dimensions (0x0).
Creates a new box with specified dimensions.
Renders the box border.
Functions
Creates a new box with default dimensions (0x0).
-spec new(term(), non_neg_integer(), non_neg_integer()) -> map().
Creates a new box with specified dimensions.
The box is a container that can hold child widgets. Children are laid out vertically with 1 character padding on all sides.
Renders the box border.
Border style changes based on focus:
- Focused or child has focus: double-line border
- Unfocused: square/single-line border