Tuix.Components (tuix v0.1.0)

Copy Markdown View Source

Functions and macros for building the element tree returned by Tuix.App.render/1.

Box props

  • :width / :height - integer cells, {:percent, n}, or a "50%" string
  • :flex_direction - :column (default) or :row
  • :flex_grow - share of leftover space along the parent's main axis
  • :gap - cells between children
  • :padding - cells inside the border on all sides
  • :border - :none (default), :single, :rounded, :double, or true (alias for :single)
  • :border_color - color of the border (see Tuix.Color)
  • :title - text drawn into the top border
  • :bg - background fill color

Text props

  • :fg / :bg - colors (see Tuix.Color)
  • :attrs - list of :bold, :dim, :italic, :underline, :blink, :reverse, :strikethrough

Examples

box border: :rounded, padding: 1, gap: 1 do
  text("Welcome", fg: :yellow)
  text("Press q to quit")
end

Summary

Functions

box(props \\ [], block_or_children \\ [])

(macro)

Builds a box element.

Accepts props and children either as a do block or as a list:

box(border: :single) # empty box
box [border: :single] do
  text("hi")
end
box([border: :single], [text("hi")])

text(content, props \\ [])

@spec text(
  String.t(),
  keyword()
) :: Tuix.Element.t()

Builds a text element.

text("Hello")
text("Hello", fg: "#00FF00", attrs: [:bold])

Multi-line content (embedded newlines) renders one line per row.