Skip to main content

Theme

Struct Theme 

Source
pub struct Theme {
    pub name: String,
    pub author: Option<String>,
    pub url: Option<String>,
    pub color_scheme: Option<ColorScheme>,
    pub colors: ThemeColors,
    pub metrics: ThemeMetrics,
    /* private fields */
}

Fields§

§name: String§author: Option<String>§url: Option<String>§color_scheme: Option<ColorScheme>§colors: ThemeColors§metrics: ThemeMetrics

Implementations§

Source§

impl Theme

Source

pub fn revision(&self) -> u64

Source

pub fn color(&self, key: ThemeColorKey) -> Color

Source

pub fn metric(&self, key: ThemeMetricKey) -> Px

Source

pub fn color_by_key(&self, key: &str) -> Option<Color>

Source

pub fn color_required(&self, key: &str) -> Color

Source

pub fn color_token(&self, key: &str) -> Color

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn syntax_color(&self, highlight: &str) -> Option<Color>

Resolve a syntax highlight tag (e.g. keyword.operator) into a theme color.

Lookup order:

  1. color.syntax.<highlight>
  2. prefix fallback: color.syntax.keyword.operator -> color.syntax.keyword
  3. built-in semantic fallbacks for common highlight roots
Source

pub fn named_color(&self, key: ThemeNamedColorKey) -> Color

Resolves a named (non-semantic) color token used by upstream ecosystems (e.g. text-white).

Source

pub fn metric_by_key(&self, key: &str) -> Option<Px>

Source

pub fn metric_required(&self, key: &str) -> Px

Source

pub fn metric_token(&self, key: &str) -> Px

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn corners_by_key(&self, key: &str) -> Option<Corners>

Source

pub fn corners_required(&self, key: &str) -> Corners

Source

pub fn corners_token(&self, key: &str) -> Corners

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn number_by_key(&self, key: &str) -> Option<f32>

Source

pub fn number_required(&self, key: &str) -> f32

Source

pub fn number_token(&self, key: &str) -> f32

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn duration_ms_by_key(&self, key: &str) -> Option<u32>

Source

pub fn duration_ms_required(&self, key: &str) -> u32

Source

pub fn duration_ms_token(&self, key: &str) -> u32

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn easing_by_key(&self, key: &str) -> Option<CubicBezier>

Source

pub fn easing_required(&self, key: &str) -> CubicBezier

Source

pub fn easing_token(&self, key: &str) -> CubicBezier

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn text_style_by_key(&self, key: &str) -> Option<TextStyle>

Source

pub fn text_style_required(&self, key: &str) -> TextStyle

Source

pub fn text_style_token(&self, key: &str) -> TextStyle

Non-panicking theme token access with diagnostics + fallback behavior.

Source

pub fn color_key_configured(&self, key: &str) -> bool

Source

pub fn metric_key_configured(&self, key: &str) -> bool

Source

pub fn corners_key_configured(&self, key: &str) -> bool

Source

pub fn number_key_configured(&self, key: &str) -> bool

Source

pub fn duration_ms_key_configured(&self, key: &str) -> bool

Source

pub fn easing_key_configured(&self, key: &str) -> bool

Source

pub fn text_style_key_configured(&self, key: &str) -> bool

Source

pub fn snapshot(&self) -> ThemeSnapshot

Source

pub fn global<H>(app: &H) -> &Theme
where H: UiHost,

Source

pub fn with_global_mut<H, R>(app: &mut H, f: impl FnOnce(&mut Theme) -> R) -> R
where H: UiHost,

Source

pub fn apply_config(&mut self, cfg: &ThemeConfig)

Source

pub fn extend_tokens_from_config(&mut self, cfg: &ThemeConfig)

Merge additional tokens from a ThemeConfig into the current theme without resetting the baseline theme (colors/metrics) or the configured-key tracking sets.

This is intended for ecosystem-driven design system presets (e.g. Material 3) that need to inject extra token kinds (motion/state/typography) on top of an existing theme preset (e.g. a shadcn color scheme in the gallery app).

Source

pub fn apply_config_patch(&mut self, cfg: &ThemeConfig)

Apply a ThemeConfig as a patch layered on top of the current theme.

Unlike Self::apply_config, this does not reset any existing token tables. This is the intended API for app-level overrides (e.g. “compact editor” metric tweaks) layered on top of an ecosystem preset (e.g. shadcn New York).

This updates the configured_* tracking sets by adding the keys present in cfg and increments the theme revision when the effective token tables change.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Theme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UiElementA11yExt for T

Source§

fn a11y(self, decoration: SemanticsDecoration) -> UiElementWithA11y<Self>

Source§

fn a11y_role(self, role: SemanticsRole) -> UiElementWithA11y<Self>

Source§

fn a11y_label(self, label: impl Into<Arc<str>>) -> UiElementWithA11y<Self>

Source§

fn a11y_value(self, value: impl Into<Arc<str>>) -> UiElementWithA11y<Self>

Source§

fn a11y_disabled(self, disabled: bool) -> UiElementWithA11y<Self>

Source§

fn a11y_selected(self, selected: bool) -> UiElementWithA11y<Self>

Source§

fn a11y_expanded(self, expanded: bool) -> UiElementWithA11y<Self>

Source§

fn a11y_checked(self, checked: Option<bool>) -> UiElementWithA11y<Self>

Source§

impl<T> UiElementKeyContextExt for T

Source§

fn key_context( self, key_context: impl Into<Arc<str>>, ) -> UiElementWithKeyContext<Self>

Source§

impl<T> UiElementTestIdExt for T

Source§

fn test_id(self, id: impl Into<Arc<str>>) -> UiElementWithTestId<Self>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more