pub struct Theme {
pub palette: Palette,
pub typography: Typography,
pub control_radius: f32,
pub card_radius: f32,
pub card_padding: f32,
pub control_padding_y: f32,
pub control_padding_x: f32,
}Expand description
The full elegance theme — colours + typography + a handful of shapes.
Fields§
§palette: PaletteColour palette driving every widget.
typography: TypographyFont sizes shared across widgets.
control_radius: f32Corner radius used for buttons, inputs, selects and segmented buttons.
card_radius: f32Corner radius used for cards.
card_padding: f32Inner padding applied to cards.
control_padding_y: f32Vertical padding inside buttons and inputs.
control_padding_x: f32Horizontal padding inside buttons.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn charcoal() -> Self
pub fn charcoal() -> Self
The “charcoal” theme: neutral dark-grey palette with a cyan
focus accent. Shares shape and typography with Theme::slate
so layouts transfer cleanly between the two.
Sourcepub fn frost() -> Self
pub fn frost() -> Self
The “frost” theme: the light-mode counterpart to
Theme::slate. Shares shape and typography so you can toggle
between the two without any layout shift.
Sourcepub fn paper() -> Self
pub fn paper() -> Self
The “paper” theme: the light-mode counterpart to
Theme::charcoal. Shares shape and typography so you can toggle
between the two without any layout shift.
Sourcepub fn install(self, ctx: &Context)
pub fn install(self, ctx: &Context)
Install the theme into an egui::Context.
This updates ctx.style() so that stock widgets (labels, sliders,
scroll bars, etc.) inherit the palette, registers the bundled
Elegance Symbols font as a lowest-priority Proportional + Monospace
fallback so glyphs like → ⌫ ⋯ render out of the box, and stores
the theme in context memory so elegance widgets can read it back.
Cheap to call every frame: when the incoming theme equals the one already installed, the style and memory writes are skipped. The font install is idempotent (by font name) inside egui.
The font registration uses Context::add_font, which appends to
the existing registry. Host fonts installed via add_font — at any
time, before or after Theme::install — coexist with the symbols
font. A host call to ctx.set_fonts(...) after Theme::install
still clobbers the symbols font (and egui’s defaults, and anything
else), but that’s inherent to set_fonts taking over the registry.
Sourcepub fn current(ctx: &Context) -> Theme
pub fn current(ctx: &Context) -> Theme
Read the currently-installed theme, or return Theme::slate if
none has been installed yet.
Source§impl Theme
impl Theme
Sourcepub fn body_text(&self, text: impl Into<String>) -> WidgetText
pub fn body_text(&self, text: impl Into<String>) -> WidgetText
Create a WidgetText coloured with the primary text colour and
sized for body copy.
Sourcepub fn heading_text(&self, text: impl Into<String>) -> WidgetText
pub fn heading_text(&self, text: impl Into<String>) -> WidgetText
Create a strong WidgetText coloured and sized for a heading.
Sourcepub fn muted_text(&self, text: impl Into<String>) -> WidgetText
pub fn muted_text(&self, text: impl Into<String>) -> WidgetText
Create a WidgetText coloured with the muted text colour.
Sourcepub fn faint_text(&self, text: impl Into<String>) -> WidgetText
pub fn faint_text(&self, text: impl Into<String>) -> WidgetText
Create a WidgetText coloured with the faint (tertiary) text colour.