class

Phosphor::Theme

Inherits Reference < Object

Maps semantic names to Style values, so widgets ask for :accent or :error rather than hardcoding colors — the same widget renders correctly whether an app uses phosphor's built-in look or a custom one.

Widget#sync is the only place that calls app.theme — MockWidget never touches it directly, keeping mocks publishable independent of any app's color choices.

See DESIGN.md § "Style and Theme" for the full rationale.

Constants

DEFAULTS = {:primary => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(24), dark: Color::Indexed.new(75))), :accent => (Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(127), dark: Color::Indexed.new(213)))).bold, :muted => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(240), dark: Color::Indexed.new(244))), :error => (Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(160), dark: Color::Indexed.new(196)))).bold, :success => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(28), dark: Color::Indexed.new(83))), :selected => Style.new.reverse, :border => Style.new.fg(AdaptiveColor.new(light: Color::Indexed.new(250), dark: Color::Indexed.new(240))), :title => Style.new.bold, :background => Style.new.bg(Color::Default.new)} of Symbol => Style

The built-in theme. Every color uses AdaptiveColor so it looks correct on both dark terminals (the common case) and light terminals (VS Code's default, many macOS users) without any configuration.

Constructors

new(styles : Hash(Symbol, Style) = DEFAULTS, border_style : BorderStyle = BorderStyle::SQUARE, focus_border_style : Style = Style.new.fg(Color::Rgb.new(85, 85, 85)), blur_border_style : Style = Style.new.fg(Color::Rgb.new(42, 42, 42)))
Source

Instance methods

[](name : Symbol) : Style

Fetches the Style registered for name. Raises KeyError naming the missing key if name isn't set — use #[]? for a safe lookup instead.

Source
[]?(name : Symbol) : Style | Nil

Fetches the Style registered for name, or nil if it isn't set.

Source
blur_border_style

Style applied to a bordered widget/screen's border when it does not hold focus — dimmer than #focus_border_style, so unfocused panels recede visually.

Source
border_style

The set of box-drawing characters Border draws with. Defaults to BorderStyle::SQUARE; pass a different predefined style (or a custom one) at construction time to change every bordered widget/screen in the app at once.

Source
focus_border_style

Style applied to a bordered widget/screen's border when it holds focus — a lighter gray than #blur_border_style so the focused panel reads as "active" without resorting to a jarring accent color.

Source
merge(overrides : Hash(Symbol, Style), border_style : BorderStyle | Nil = nil, focus_border_style : Style | Nil = nil, blur_border_style : Style | Nil = nil) : Theme

Returns a new Theme with overrides layered on top of this one — keys in overrides replace this theme's value for that key; every other key keeps its current value. border_style, focus_border_style, and blur_border_style follow the same rule: pass a value to override it, or omit it (leave nil) to carry forward this theme's current value. Does not mutate self.

Source