lipgloss-list
A list component for Terminal UIs, styled with Lip Gloss. This crate is part of the lipgloss-rs ecosystem and aims for 1:1 API and rendering parity with Charm's Go implementation.
- Simple and nested lists (sublists)
- Predefined enumerators:
alphabet,arabic,roman,bullet,dash,asterisk - Custom enumerators and custom indenter support
- Per-item styling and enumerator styling via style functions
- Multiline items with correct alignment
Installation
Use the batteries-included facade (recommended):
[]
= { = "0.0.8", = ["lists"] }
Or depend directly on the component (add lipgloss for styling):
[]
= "0.0.8"
= "0.0.8"
Quick start
use List;
let l = new
.items;
println!;
Output:
• A
• B
• C
Enumerators
Pick from built-ins or define your own.
use ;
let a = new.items.enumerator;
let r = new.items.enumerator;
let ab = new.items.enumerator;
let b = new.items.enumerator;
let d = new.items.enumerator;
let s = new.items.enumerator;
println!;
Define a custom enumerator:
use Children;
use List;
let l = new.items.enumerator;
println!;
Sublists (nested lists)
Sublists are just lists as items.
use ;
let l = new
.item
.item
.item_list
.item;
println!;
Which renders like:
• A
• B
I. C1
II. C2
III. C3
• D
Styling items and enumerators
Use style functions to style items and/or enumerators based on index or context.
use ;
use List;
use Children;
let l = new
.items
.item_style_func
.enumerator_style_func;
println!;
Apply a base style to all items or all enumerators:
use ;
use List;
let l = new
.items
.item_style
.enumerator_style;
println!;
Custom indentation
Change indentation for nested content via indenter.
use List;
use Children;
let l = new
.items
.indenter;
println!;
Note: lists default to a two-space indenter for sublists, matching golden output.
Offsets and hiding
offset(start, end)shows only a subset of items, useful for paging.hide(true)hides the entire list.
use List;
let visible_slice = new.items.offset;
let hidden = new.items.hide;
println!;
assert_eq!;
Multiline items
Items can contain newlines; continuation lines are indented correctly.
use List;
let l = new.items;
println!;
Demos
Run from the repository root:
Notes
- Lists are built on top of
lipgloss-treeand benefit from its Unicode-aware layout rules. - Roman numerals alignment is handled to match Go’s output.
- Nesting trees and tables inside lists is supported; deep complex nestings match golden coverage (with one known spacing discrepancy documented in
docs/TREE_IN_LIST_SPACING_ISSUE.md).
Documentation
- API docs:
https://docs.rs/lipgloss-list - Project:
https://github.com/whit3rabbit/lipgloss-rs
License
MIT