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);

Item text and highlight symbols are clipped to the render area's width, without splitting wide characters or drawing into neighboring panels. Highlight alignment and trailing padding use terminal display columns rather than UTF-8 byte counts.

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