Class: RatatuiRuby::Widgets::ListItem

Inherits:
Object
  • Object
show all
Includes:
CoerceableWidget
Defined in:
lib/ratatui_ruby/widgets/list_item.rb

Overview

A styled list item combining content with optional style.

By default, List items are strings. For more control over styling individual rows, wrap the content in a ListItem to apply a style specific to that item.

The content can be a String, Text::Span, or Text::Line. The style applies to the entire row background.

Examples

– SPDX-SnippetBegin SPDX-FileCopyrightText: 2026 Kerrick Long SPDX-License-Identifier: MIT-0 ++

# Item with red background
ListItem.new(content: "Error", style: Style.new(bg: :red))

# Item with styled content
ListItem.new(
  content: Text::Span.new(content: "Status: OK", style: Style.new(fg: :green, modifiers: [:bold]))
)

– SPDX-SnippetEnd ++

Instance Method Summary collapse

Methods included from CoerceableWidget

included

Constructor Details

#initialize(content:, style: nil) ⇒ ListItem

Creates a new ListItem.

content

String, Text::Span, or Text::Line.

style

Style object (optional).



50
51
52
# File 'lib/ratatui_ruby/widgets/list_item.rb', line 50

def initialize(content:, style: nil)
  super
end