Packages
Multi-surface application runtime for Elixir. One TEA module renders to terminal, browser (LiveView), SSH, and MCP (agents). 30+ widgets, flexbox + CSS grid, AI agent runtime, distributed swarm with CRDTs, time-travel debugging, session recording, sandboxed REPL, and agentic commerce.
Current section
Files
Jump to
Current section
Files
lib/raxol/ui/layout/inputs.ex
defmodule Raxol.UI.Layout.Inputs do
@moduledoc """
Handles measurement of input elements like buttons and text inputs.
"""
@button_padding 4
@button_height 3
@input_padding 4
@input_height 3
def measure(:button, attrs_map, available_space) do
text = Map.get(attrs_map, :label, "Button")
width = min(String.length(text) + @button_padding, available_space.width)
%{width: width, height: @button_height}
end
def measure(:text_input, attrs_map, available_space) do
value = Map.get(attrs_map, :value, "")
placeholder = Map.get(attrs_map, :placeholder, "")
display_text =
case value == "" do
true -> placeholder
false -> value
end
width =
min(String.length(display_text) + @input_padding, available_space.width)
%{width: width, height: @input_height}
end
end