class

Egui::StyleVars

Inherits Hash < Iterable < Enumerable < Reference < Object

A mergeable bag of style variables: Hash(String, StyleValue) with typed getters (untyped keys simply stay invisible to a getter, so typos degrade to "unset", never to a crash). Bags produced by StyleSheet#resolve are shared caches — treat them as read-only.

Instance methods

apply_over(base : Style) : Style

Apply this bag onto a copy of base (the same key vocabulary WidgetStyle#merge_over uses), mapping keys onto their Style slots. background is deliberately NOT mapped here: it is state-scoped, so state-painted widgets read it from the state-merged bag through Widget#background_color instead of a flat Style slot. Skips cloning for empty bags.

Source
bool(key : String, fallback : Bool) : Bool
Source
bool?(key : String) : Bool | Nil
Source
box(prefix : String) : StyleBox

The four-sided box under prefix ("padding", "margin", …): prefix.top/left/right/bottom, each side falling back to the scalar prefix shorthand (CSS padding: 12px sets all sides), missing sides to 0. Negative sides clamp to 0 — this layout engine has no notion of "padding pulling content outside the widget", so a negative value only made text overflow its rect.

Source
box?(prefix : String) : StyleBox | Nil

Same, but nil when no box key is set at all (callers fall back to their own default, e.g. Spacing#button_padding).

Source
color(key : String, fallback : Color32) : Color32
Source
color?(key : String) : Color32 | Nil
Source
f64(key : String, fallback : Float64) : Float64
Source
f64?(key : String) : Float64 | Nil

Integers coerce (CSS vibes: {"height" => 24} reads as 24.0).

Source
shadow?(prefix : String = "shadow") : BoxShadowSpec | Nil

The CSS box-shadow under prefix ("shadow" by default): requires shadow.color (a shadow without a color is nothing), everything else defaults — blur/spread/offset 0, outset. Flat scalar keys like #box?, so the mergeable-bag cascade works per key: a button:active rule may flip only shadow.inset and the class defaults fill in the rest.

Source
str?(key : String) : String | Nil

String values (font families, class names…).

Source