A selectable list widget.
Fields
:items- list of items to display. Each item accepts anyExRatatui.Text-coercible value: aString.t(), a%ExRatatui.Text.Span{}, a%ExRatatui.Text.Line{}, a%ExRatatui.Text{}, or a list of spans/lines.:style-%ExRatatui.Style{}for non-selected items:block- optional%ExRatatui.Widgets.Block{}container:highlight_style-%ExRatatui.Style{}for the selected item:highlight_symbol- string prefix for the selected item (e.g.,">> "):selected- zero-based index of the selected item, ornilfor no selection. Must be in0..length(items) - 1; any other value raisesArgumentErrorat render time.:direction-:top_to_bottom(default) or:bottom_to_top. The latter paints the first item at the bottom of the area and grows upward — natural fit for chat logs, REPL history, and event streams where the newest entry pins to the bottom edge.:scroll_padding- non-negative integer. The minimum number of rows kept visible above and below the selected item when the list auto-scrolls.2means the selection always has at least two rows of context on each side (or as many as the viewport allows). Defaults to0.:repeat_highlight_symbol-false(default) renders the highlight symbol only on the first wrapped row of the selected item;truerepeats it on every row. Useful for multi-line list items.
Examples
iex> %ExRatatui.Widgets.List{items: ["Alpha", "Beta", "Gamma"], selected: 0}
%ExRatatui.Widgets.List{
items: ["Alpha", "Beta", "Gamma"],
style: %ExRatatui.Style{},
block: nil,
highlight_style: %ExRatatui.Style{},
highlight_symbol: nil,
selected: 0,
direction: :top_to_bottom,
scroll_padding: 0,
repeat_highlight_symbol: false
}
Summary
Types
@type direction() :: :top_to_bottom | :bottom_to_top
@type item() :: String.t() | ExRatatui.Text.Span.t() | ExRatatui.Text.Line.t() | ExRatatui.Text.t() | [ExRatatui.Text.Span.t()] | [ExRatatui.Text.Line.t()]
@type t() :: %ExRatatui.Widgets.List{ block: ExRatatui.Widgets.Block.t() | nil, direction: direction(), highlight_style: ExRatatui.Style.t(), highlight_symbol: String.t() | nil, items: [item()], repeat_highlight_symbol: boolean(), scroll_padding: non_neg_integer(), selected: non_neg_integer() | nil, style: ExRatatui.Style.t() }