Expand description
Default item implementation and delegate for basic list functionality.
This module provides ready-to-use implementations for common list use cases:
DefaultItem: A simple string-based item with title and descriptionDefaultDelegate: A delegate that renders items with proper highlightingDefaultItemStyles: Customizable styling for default item rendering
These components handle fuzzy match highlighting, cursor styling, and basic item representation without requiring custom implementations.
§Examples
use bubbletea_widgets::list::{Model, DefaultDelegate, DefaultItem};
let items = vec![
DefaultItem::new("Task 1", "Complete documentation"),
DefaultItem::new("Task 2", "Review pull requests"),
];
let list = Model::new(items, DefaultDelegate::new(), 80, 24);Default item implementation and delegate for list components.
This module provides the standard item type and delegate implementation for the list component.
The DefaultItem is a simple item with a title and description, while DefaultDelegate handles
the rendering and interaction logic for these items.
§Filter Highlighting Architecture
This module implements a sophisticated filter highlighting system that avoids common ANSI rendering issues. The key insight is that lipgloss styles with padding/borders cause spacing problems when applied to individual text segments.
§The Problem
When highlighting individual characters in filtered text, naively applying styles with padding results in extra spaces between segments:
- Input: “Nutella” with ‘N’ highlighted
- Broken: “│ N utella” (space between N and utella)
- Correct: “│ Nutella” (seamless text)
§The Solution
- Segment-Based Highlighting: Group consecutive match indices to minimize ANSI sequences
- Clean Styles: Use styles without padding/borders for
apply_character_highlighting - Manual Layout: Apply borders and padding manually after highlighting is complete
§Visual States
- Selected Items: Left border (│) + 1 space + highlighted text
- Unselected Items: 2 spaces + highlighted text (no border)
- Dimmed Items: Faded colors when filter input is empty
This approach ensures perfect text rendering while maintaining the visual hierarchy.
§Default Item Structure
The DefaultItem represents a basic list item with:
- A title (main text)
- A description (secondary text, optional display)
§Default Delegate
The DefaultDelegate handles:
- Rendering items with different visual states (normal, selected, dimmed)
- Managing item height and spacing
- Complex filter highlighting with seamless text rendering
§Styling
The DefaultItemStyles provides comprehensive styling options:
- Normal state styles for title and description
- Selected state styles with borders and highlighting
- Dimmed state styles for filtered-out items
- Filter match highlighting styles
§Example
use bubbletea_widgets::list::{DefaultItem, DefaultDelegate};
let item = DefaultItem::new("Task 1", "Complete the documentation");
let delegate = DefaultDelegate::new();Structs§
- Default
Delegate - A delegate for rendering
DefaultIteminstances in list components. - Default
Item - A simple list item with title and description text.
- Default
Item Styles - Styling configuration for default list items in various visual states.