Skip to main content

DefaultTheme

Struct DefaultTheme 

Source
pub struct DefaultTheme {
Show 25 fields pub fonts: ThemeFontFamilies, pub colors: ThemeColors, pub density: ThemeDensity, pub control_size: Option<ControlSize>, pub spacing: f32, pub breakpoints: ThemeBreakpoints, pub containers: ThemeContainers, pub text: ThemeTextScale, pub font_weights: ThemeFontWeights, pub tracking: ThemeTracking, pub leading: ThemeLeading, pub radius: ThemeRadii, pub shadows: ThemeShadows, pub glows: ThemeGlows, pub blur: ThemeBlurScale, pub perspective: ThemePerspective, pub aspect: ThemeAspectRatios, pub motion: ThemeMotion, pub hdr: HdrThemeTokens, pub palette: ControlPalette, pub surfaces: SurfacePalette, pub decorative: DecorativePalette, pub typography: ControlTypography, pub interaction: ControlStateMetrics, pub metrics: ControlMetrics,
}

Fields§

§fonts: ThemeFontFamilies§colors: ThemeColors§density: ThemeDensity§control_size: Option<ControlSize>

Contextual authored size, when this theme copy is scoped to an interface surface.

§spacing: f32§breakpoints: ThemeBreakpoints§containers: ThemeContainers§text: ThemeTextScale§font_weights: ThemeFontWeights§tracking: ThemeTracking§leading: ThemeLeading§radius: ThemeRadii§shadows: ThemeShadows§glows: ThemeGlows

Live-signal glow halos (--sm-glow-*): empty in Light, damped in the true-black theme. Paint with paint_theme_shadow.

§blur: ThemeBlurScale§perspective: ThemePerspective§aspect: ThemeAspectRatios§motion: ThemeMotion§hdr: HdrThemeTokens§palette: ControlPalette§surfaces: SurfacePalette§decorative: DecorativePalette

Derived roles for the categorical decorative hues.

§typography: ControlTypography§interaction: ControlStateMetrics§metrics: ControlMetrics

Implementations§

Source§

impl DefaultTheme

Source

pub fn new() -> Self

Source

pub fn sui() -> Self

SUI’s branded default theme.

Source

pub fn light() -> Self

Pure white and gray surfaces with the vibrant SUI azure accent.

Source

pub fn neutral() -> Self

A neutral light theme for serious, professional interfaces without an application-specific color preference.

Source

pub fn neutral_dark() -> Self

Dark companion to Self::neutral.

Source

pub fn dark() -> Self

Faintly blue-tinted dark surfaces with the SUI azure accent.

Source

pub fn high_contrast() -> Self

Source

pub fn void() -> Self

The true-black OLED theme (“Void”): borders instead of shadows, dimmed whites, damped glows. Alias for Self::high_contrast.

Source

pub fn compact() -> Self

Source

pub fn comfortable() -> Self

Source

pub fn touch() -> Self

Source

pub fn from_colors(colors: ThemeColors) -> Self

Build a theme from source colors, deriving every palette role. The built-in presets cache their result; call this for custom palettes.

Source

pub fn with_density(self, density: ThemeDensity) -> Self

Source

pub fn with_size(self, size: ControlSize) -> Self

Apply contextual interface sizing without changing the text-scale ramp.

The existing density tiers provide the mature detailed metric ladders behind Small, Medium, and Large. The authored size contract then normalizes the primary control, row, icon, and control-text tokens while leaving the caller’s text ramp intact.

Source

pub fn sync_derived_fields(&mut self)

Source

pub fn text_style(&self, color: Color) -> TextStyle

Source

pub fn serif_text_style(&self, color: Color) -> TextStyle

Build a text style using the theme’s serif family preference stack.

Source

pub fn mono_text_style(&self, color: Color) -> TextStyle

Build a text style using the theme’s monospace family preference stack.

Source

pub fn semantic_tone_colors(&self, tone: SemanticTone) -> (Color, Color)

Source

pub fn glow_for_output( &self, tone: GlowTone, output: Option<OutputColorRange>, ) -> ThemeShadow

The theme’s tone glow as it should look on output.

Where the theme’s HDR mode and the output allow it, each halo takes the HDR variant of the tone’s color, as bright as an emissive indicator may be, or its wide-gamut variant on a wide-gamut output, keeping the halo’s own alpha. Elsewhere, and whenever the theme turns HDR effects off, the glow is the theme’s token. Light themes have no glow.

Source

pub fn tone_roles(&self, tone: SemanticTone) -> ToneRoles

The complete role set for a semantic tone. Neutral resolves to the neutral button face: white with an outline in light themes, a raised fill in dark themes, always with full-strength ink.

Source

pub fn semantic_tone_color(&self, tone: SemanticTone) -> Color

Source

pub fn semantic_tone_text_color(&self, tone: SemanticTone) -> Color

Source

pub fn semantic_tone_soft_colors(&self, tone: SemanticTone) -> (Color, Color)

Soft pair for an explicitly semantic tone: a restrained wash to fill with and tone-hued ink that stays legible on it. Use for badges and callouts; selected rows use the neutral selection role. The solid pair from Self::semantic_tone_colors is for filled controls.

Source

pub fn for_disabled_control(self) -> Self

This theme as a disabled control draws with it: text and placeholders take the disabled ink, fills fade toward the control tier, and borders and accents lose strength, so a widget that paints with the result looks disabled without colors of its own.

Source

pub fn body_text_style(&self) -> TextStyle

Source

pub fn placeholder_text_style(&self) -> TextStyle

Source

pub fn button_text_style(&self) -> TextStyle

Trait Implementations§

Source§

impl Clone for DefaultTheme

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for DefaultTheme

Source§

impl Debug for DefaultTheme

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DefaultTheme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for DefaultTheme

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DefaultTheme

Auto Trait Implementations§

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.