class RatatuiRuby::Style
Defines colors and text modifiers.
The terminal is traditionally monochrome, but efficient interfaces use color to convey meaning. Red for errors. Green for success. Bold for headers.
This value object encapsulates those choices. It applies foreground and background colors. It adds effects like italics or blinking.
Use it to theme your application or highlight critical data.
Examples
# Standard colors Style.new(fg: :red, bg: :white, modifiers: [:bold]) # Hex colors Style.new(fg: "#ff00ff")
Supported Colors
Integer
Represents an indexed color from the Xterm 256-color palette (0-255).
-
0–15: Standard and bright ANSI colors. -
16–231: 6x6x6 Color Cube. -
232–255: Grayscale ramp.
Symbol
Represents a named color from the standard ANSI palette. Supported values:
-
:black,:red,:green,:yellow,:blue,:magenta,:cyan,:gray -
:dark_gray,:light_red,:light_green,:light_yellow,:light_blue,:light_magenta,:light_cyan,:white
String
Represents a specific RGB color using a Hex code ("#RRGGBB"). Requires a terminal emulator with “True Color” (24-bit color) support.
Styling primitives for colors and text effects.
This module mirrors ratatui::style and contains:
-
{Style} — Colors and modifiers
Attributes
Background color.
Symbol (:black), Hex String ("#000000"), or Integer (0-255).
Foreground color.
Symbol (:red), Hex String ("#ffffff"), or Integer (0-255).
Text effects.
Array of symbols: :bold, :dim, :italic, :underlined, :slow_blink, :rapid_blink, :reversed, :hidden, :crossed_out.
Public Class Methods
Source
# File lib/ratatui_ruby/schema/style.rb, line 93 def self.default new end
Returns an empty style.
Use this as a baseline to prevent style inheritance issues or when no styling is required.
Source
# File lib/ratatui_ruby/schema/style.rb, line 86 def initialize(fg: nil, bg: nil, modifiers: []) super end
Creates a new Style.
- fg
-
Color (Symbol/String/Integer).
- bg
-
Color (Symbol/String/Integer).
- modifiers
-
Array of Symbols.