Skip to main content

ThemeTokens

Trait ThemeTokens 

Source
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§

Source

fn primary(&self) -> Color

Source

fn on_primary(&self) -> Color

Source

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).

Source

fn spacing(&self) -> f32

Base gap between adjacent things in px, and the unit a component derives its own padding from.

Source

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.

Source

fn icon_size(&self) -> f32

Default size of a standalone icon in px.

Source

fn muted(&self) -> Color

Source

fn scrollbar(&self) -> Color

Source

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.

Source

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.

Source

fn surface_alt(&self) -> Color

A quiet, low-contrast surface tone for chip/tag backgrounds. Defaults to a faint neutral wash.

Source

fn border(&self) -> Color

Hairline border/divider tone. Defaults to a faint neutral.

Source

fn success(&self) -> Color

Semantic status colours. Defaults are conventional hues; a theme should override to match its palette.

Source

fn warning(&self) -> Color

Source

fn error(&self) -> Color

Source

fn info(&self) -> Color

Source

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.

Source

fn highlight_med(&self) -> Color

Source

fn highlight_high(&self) -> Color

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§