pub trait ThemeTokens: 'static {
Show 19 methods
// Provided methods
fn primary(&self) -> Color { ... }
fn on_primary(&self) -> Color { ... }
fn radius(&self) -> f32 { ... }
fn spacing(&self) -> f32 { ... }
fn font_size(&self) -> f32 { ... }
fn icon_size(&self) -> f32 { ... }
fn muted(&self) -> Color { ... }
fn scrollbar(&self) -> Color { ... }
fn ink(&self) -> Color { ... }
fn surface(&self) -> Color { ... }
fn surface_alt(&self) -> Color { ... }
fn border(&self) -> Color { ... }
fn success(&self) -> Color { ... }
fn warning(&self) -> Color { ... }
fn error(&self) -> Color { ... }
fn info(&self) -> Color { ... }
fn highlight_low(&self) -> Color { ... }
fn highlight_med(&self) -> Color { ... }
fn highlight_high(&self) -> Color { ... }
}Expand description
Opt-in semantic-token contract the built-in component catalogue reads through, so a component can resolve a token without knowing the concrete theme type.
Every method carries a default, which makes impl ThemeTokens for MyTheme {} valid and each token an
independent opt-in: a theme answers the questions it cares about and lets the catalogue keep its own answer
for the rest. This trait is deliberately not where a theme’s vocabulary lives — that belongs to the theme’s
own type, reachable in full through use_theme. What is here is only the subset a component written
without knowledge of that type has to be able to ask for.
The metric tokens are bases, not a size scale. A catalogue component derives its own proportions from
font_size rather than asking for a named role, because naming the roles would decide for
every application which roles may exist. One number scales the type; the component keeps its own ratios.
Provided Methods§
fn primary(&self) -> Color
fn on_primary(&self) -> Color
Sourcefn radius(&self) -> f32
fn radius(&self) -> f32
Base corner radius in px. A component rounds by this, or by a multiple of it where its shape asks for one (a pill is not a card).
Sourcefn spacing(&self) -> f32
fn spacing(&self) -> f32
Base gap between adjacent things in px, and the unit a component derives its own padding from.
Sourcefn font_size(&self) -> f32
fn font_size(&self) -> f32
Base body text size in px. Every catalogue component scales its own text off this, so changing it scales the whole type ramp.
fn muted(&self) -> Color
fn scrollbar(&self) -> Color
Sourcefn ink(&self) -> Color
fn ink(&self) -> Color
Primary text ink for component labels/titles/values. Defaults to a near-black; a theme should override it (e.g. a dark theme returns a light ink) so component text stays legible on its surface.
Sourcefn surface(&self) -> Color
fn surface(&self) -> Color
The background a floating panel sits on — a menu, a dropdown, a dialog. Opaque by default, because the thing it covers must not read through it.
Sourcefn surface_alt(&self) -> Color
fn surface_alt(&self) -> Color
A quiet, low-contrast surface tone for chip/tag backgrounds. Defaults to a faint neutral wash.
Sourcefn success(&self) -> Color
fn success(&self) -> Color
Semantic status colours. Defaults are conventional hues; a theme should override to match its palette.
fn warning(&self) -> Color
fn error(&self) -> Color
fn info(&self) -> Color
Sourcefn highlight_low(&self) -> Color
fn highlight_low(&self) -> Color
Three progressively stronger highlight/elevation tints for hover, selection, and pressed states. Defaults to faint neutral washes a theme can override with palette-specific tones.
fn highlight_med(&self) -> Color
fn highlight_high(&self) -> Color
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".