class RatatuiRuby::Widgets::Row
A styled table row combining cells with optional row-level styling.
By default, Table rows are arrays of cell content. For more control over styling individual rows, wrap the cells in a Row object to apply row-level style.
The cells can be Strings, Text::Spans, Text::Lines, Paragraphs, or Cells. The style applies to the entire row background.
Examples
# Row with red background Row.new(cells: ["Error", "Something went wrong"], style: Style.new(bg: :red)) # Row with styled cells and custom height Row.new( cells: [ Text::Span.new(content: "Status", style: Style.new(modifiers: [:bold])), Text::Span.new(content: "OK", style: Style.new(fg: :green)) ], height: 2 )
Attributes
Margin below the row in lines (optional Integer).
The cells to display (Array of Strings, Text::Spans, Text::Lines, Paragraphs, or Cells).
Fixed row height in lines (optional Integer).
Margin above the row in lines (optional Integer).
Public Class Methods
Source
# File lib/ratatui_ruby/widgets/row.rb, line 69 def initialize(cells:, style: nil, height: nil, top_margin: nil, bottom_margin: nil) super( cells:, style:, height: height.nil? ? nil : Integer(height), top_margin: top_margin.nil? ? nil : Integer(top_margin), bottom_margin: bottom_margin.nil? ? nil : Integer(bottom_margin) ) end
Creates a new Row.
- cells
-
Array of Strings, Text::Spans, Text::Lines, Paragraphs, or Cells.
- style
-
Styleobject (optional). - height
-
Integer for fixed height (optional).
top_margin-
Integer for top margin (optional).
bottom_margin-
Integer for bottom margin (optional).
Public Instance Methods
Source
# File lib/ratatui_ruby/widgets/row.rb, line 110 def enable_strikethrough current_style = style || Style::Style.new current_modifiers = current_style.modifiers || [] new_modifiers = current_modifiers.include?(:crossed_out) ? current_modifiers : current_modifiers + [:crossed_out] new_style = current_style.with(modifiers: new_modifiers) with(style: new_style) end
Returns a new Row with strikethrough styling enabled.
Table rows sometimes need strikethrough styling to indicate deleted, deprecated, or cancelled items. Manually managing style modifiers is tedious.
This method adds the :crossed_out modifier to the row’s style. If the row has no existing style, a new style is created.
Use it to visually mark rows as cancelled, completed, or invalid.
*Terminal Compatibility:* Strikethrough (SGR 9) is not universally supported. macOS Terminal.app notably lacks support. Modern terminals like Kitty, iTerm2, Alacritty, and WezTerm render it correctly. Consider pairing with :dim as a fallback for visibility.
Returns a new Row instance with strikethrough enabled.
Example
row = Row.new(cells: ["Cancelled Task", "2024-01-15"]) strikethrough_row = row.enable_strikethrough # Row style now includes :crossed_out modifier