TermUI.Widget.Block (TermUI v1.0.0)

View Source

A container widget that draws a border around its content.

Block is the fundamental layout container. It renders a border, optional title, and manages the layout of children within its bordered area.

This module uses the earlier TermUI.Widget namespace and accepts a props map directly. It is not mounted by TermUI.Runtime; call its state/render callbacks explicitly. Its TermUI.Container child callbacks require a custom host and are not interpreted by the Elm runtime.

Usage

Block.render(%{
  border: :single,
  title: "Panel"
}, state, area)

Props

  • :border - Border style: :none, :single, :double, :rounded, :thick
  • :title - Optional title text
  • :title_align - Title alignment: :left, :center, :right
  • :padding - Padding inside border (integer or map with :top, :right, :bottom, :left)
  • :style - Border style options

Summary

Functions

Gets the ID from a child spec.

Gets the module from a child spec.

Gets the props from a child spec.

Returns children to render.

Handles events for the block.

Initializes the block state.

Calculates the inner area after border and padding.

Calculates layout for children within the block.

Normalizes a child spec to always have an ID.

Renders the block border and content area.

Functions

child_id(arg)

Gets the ID from a child spec.

child_module(arg)

Gets the module from a child spec.

child_props(arg)

Gets the props from a child spec.

children(state)

Returns children to render.

handle_event(event, state)

Handles events for the block.

init(props)

Initializes the block state.

inner_area(props, area)

Calculates the inner area after border and padding.

layout(children, area, area)

Calculates layout for children within the block.

normalize_child_spec(arg)

Normalizes a child spec to always have an ID.

render(state, area)

Renders the block border and content area.