Skip to content

U0010 egui-shared-theme

Rule: Every egui app installs the shared theme.

Code U0010 (stable, never reused)
Id egui-shared-theme
Category egui
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded off
ui off
egui warn every app looks alike when it installs ve_theme; an app that does not is an app of its own
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
entry-calls list of strings ["eframe::run_native", "eframe::run_simple_native"] calls that start an app
setup-calls list of strings ["ve_theme::setup", "ve_theme::setup_with"] calls that install the shared theme
toolkits list of strings ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"] UI toolkits: a crate that depends on one directly is a UI crate, unless the crate map says ui = false

Why

Apps look and behave alike when they share one theme: colours, spacing, radii and type from one set of tokens. In egui that is ve_theme::setup at start-up; an app that skips it draws egui's default look, and its own colours and sizes creep in.

The lint reports a call of entry-calls (eframe::run_native) in a crate that never calls one of setup-calls (ve_theme::setup). Findings are estimates: a crate that starts its app through a shell that installs the theme for it (vhrd_egui's ve_app) does not call run_native itself.

How to fix

Call ve_theme::setup(&cc.egui_ctx) in the app's creation closure, before the first frame.

Configure

[lints.egui-shared-theme]
level = "deny"
entry-calls = ["eframe::run_native", "eframe::run_simple_native"]
setup-calls = ["ve_theme::setup", "ve_theme::setup_with"]
toolkits = ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(egui-shared-theme) <reason> (waivers); the code works there too, as in [lints.U0010].