Skip to main content

List

Scrollable, selectable list widget with optional highlight.

Usage

const items = [_]tui.widgets.ListItem{
.{ .content = "Item one" },
.{ .content = "Item two", .style = .{ .fg = .yellow } },
};

var list = tui.widgets.List{
.items = &items,
.selected = 0,
.highlight_style = .{ .fg = .black, .bg = .cyan },
.highlight_symbol = "▶ ",
};
list.render(area, buf);

Call these once per key event to move the selection:

list.selectNext();
list.selectPrevious();
list.scrollToSelected(area.height); // keep selected row visible

ListItem fields

FieldTypeDescription
content[]const u8Display text
styleStylePer-item style override