View Source ElementTui.Element (ElementTui v0.5.1)

Elements are the core of the TUI layout. They are composable so that you can build complex layouts from simple elements.

# Create a text element with width 10
Element.text("Hello") |> Element.width(10)

Summary

Functions

Create a blank line.

The element has flexible size, i.e. can shrink and grow (in the provided direction).

Keep the element focused/on the screen. Only works when part of a vbox that is passed the [scroll: true] option.

Repeat the element horizontally to fill the available space.

Plot multiple layers on top of each other. Ensures that the layers are drawn in the correct order.

Similar to Element.text, but will assume the text is a single line and does not contain any newlines.

Opts can contain scroll: true

Functions

Link to this function

background_colour(element, colour)

View Source

Create a blank line.

Link to this function

flex(element, direction)

View Source
Link to this function

flex(element, direction, weight)

View Source

The element has flexible size, i.e. can shrink and grow (in the provided direction).

@param direction The direction in which the element should shrink or grow. Can be :horizontal, :vertical or :all @param weight The relative weight of this element versus other expanding elements. 1.0 is the default.

Keep the element focused/on the screen. Only works when part of a vbox that is passed the [scroll: true] option.

Uses ElementTui.FocusStream under the hood. If possible it is recommended to use the ElementTui.FocusStream module directly instead.

Link to this function

height(element, height, on_height_exceeded \\ fn x, _ -> x end)

View Source

Repeat the element horizontally to fill the available space.

Plot multiple layers on top of each other. Ensures that the layers are drawn in the correct order.

Link to this function

margin(element, margins)

View Source
Link to this function

margin(element, margins, borders)

View Source

Similar to Element.text, but will assume the text is a single line and does not contain any newlines.

This is useful for creating elements that are not wrapped and results in higher performance.

Link to this function

vbox(elements, opts \\ [])

View Source

Opts can contain scroll: true