class Opal::Theme

Overview

Represents a semantic color and styling theme for consistent, accessible TUI interfaces.

Defined in:

opal/style/theme.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.[](name : Symbol | String) : Theme #

[View source]
def self.build(name : String, &block : ThemeBuilder -> Nil) : Theme #

Declarative Theme Builder DSL entry point


[View source]
def self.catppuccin_latte : Theme #

[View source]
def self.catppuccin_mocha : Theme #

[View source]
def self.current : Theme #

[View source]
def self.current=(theme : Theme | Symbol | String) : Theme #

[View source]
def self.cyberpunk : Theme #

[View source]
def self.default : Theme #

[View source]
def self.dracula : Theme #

[View source]
def self.from_brand(name : String, brand : Color | String | Symbol, mode : Symbol = :dark) : Theme #

Generates a balanced, harmonious theme from a single brand color and dark/light mode


[View source]
def self.get(name : Symbol | String) : Theme #

[View source]
def self.gruvbox : Theme #

[View source]
def self.high_contrast : Theme #

[View source]
def self.monokai : Theme #

[View source]
def self.new(name : String, primary : Color, secondary : Color, accent : Color, background : Color, surface : Color, text : Color, text_muted : Color, border : Color, success : Color, warning : Color, danger : Color, info : Color, window_border : Border = Border.rounded, box_border : Border = Border.rounded, glyphs : GlyphSet = GlyphSet.new) #

[View source]
def self.nord : Theme #

[View source]
def self.register(theme : Theme) : Theme #

[View source]
def self.solarized_dark : Theme #

[View source]
def self.tokyo_night : Theme #

[View source]

Class Method Detail

def self.all : Array(Theme) #

[View source]
def self.find(name : Symbol | String) : Theme | Nil #

[View source]

Instance Method Detail

def accent : Color #

[View source]
def accent=(accent : Color) #

[View source]
def audit_contrast : Hash(String, NamedTuple(ratio: Float64, compliant: Bool, level: String)) #

Audits theme contrast ratios against WCAG 2.1 criteria


[View source]
def background : Color #

[View source]
def background=(background : Color) #

[View source]
def border : Color #

[View source]
def border=(border : Color) #

[View source]
def box_border : Border #

[View source]
def box_border=(box_border : Border) #

[View source]
def danger : Color #

[View source]
def danger=(danger : Color) #

[View source]
def derive(name : String, primary : Color | String | Symbol | Nil = nil, secondary : Color | String | Symbol | Nil = nil, accent : Color | String | Symbol | Nil = nil, background : Color | String | Symbol | Nil = nil, surface : Color | String | Symbol | Nil = nil, text : Color | String | Symbol | Nil = nil, text_muted : Color | String | Symbol | Nil = nil, border : Color | String | Symbol | Nil = nil, success : Color | String | Symbol | Nil = nil, warning : Color | String | Symbol | Nil = nil, danger : Color | String | Symbol | Nil = nil, info : Color | String | Symbol | Nil = nil, window_border : Border | Symbol | String | Nil = nil, box_border : Border | Symbol | String | Nil = nil, glyphs : GlyphSet | Nil = nil) : Theme #

Returns a new theme derived from this theme with selective overrides


[View source]
def ensure_contrast(min_ratio : Float64 = 4.5) : Theme #

Adjusts text and primary contrast against background to satisfy minimum WCAG ratio


[View source]
def glyphs : GlyphSet #

[View source]
def glyphs=(glyphs : GlyphSet) #

[View source]
def info : Color #

[View source]
def info=(info : Color) #

[View source]
def name : String #

[View source]
def primary : Color #

[View source]
def primary=(primary : Color) #

[View source]
def secondary : Color #

[View source]
def secondary=(secondary : Color) #

[View source]
def success : Color #

[View source]
def success=(success : Color) #

[View source]
def surface : Color #

[View source]
def surface=(surface : Color) #

[View source]
def text : Color #

[View source]
def text=(text : Color) #

[View source]
def text_muted : Color #

[View source]
def text_muted=(text_muted : Color) #

[View source]
def warning : Color #

[View source]
def warning=(warning : Color) #

[View source]
def window_border : Border #

[View source]
def window_border=(window_border : Border) #

[View source]