pub struct Theme {Show 14 fields
pub scheme: ColorScheme,
pub palette: Palette,
pub primary_color: ColorName,
pub primary_shade_light: usize,
pub primary_shade_dark: usize,
pub white: Color,
pub black: Color,
pub spacing: Scale,
pub radius: Scale,
pub font_size: Scale,
pub default_radius: Size,
pub line_height: f32,
pub font_family: SharedString,
pub overrides: Overrides,
}Expand description
The active theme. Install once with Theme::init, read with theme.
Fields§
§scheme: ColorScheme§palette: Palette§primary_color: ColorNameThe color used for default-variant filled controls.
primary_shade_light: usizeShade index of the primary color in light / dark mode.
primary_shade_dark: usize§white: Color§black: Color§spacing: Scale§radius: Scale§font_size: Scale§default_radius: SizeDefault corner radius for components that don’t specify one.
line_height: f32§font_family: SharedString§overrides: OverridesOptional CSS-color overrides for the scheme-derived semantic colors and
the primary accent. When set, the matching getter returns the override.
Set them with the with_* builders (e.g. Theme::dark().with_body(..)).
Implementations§
Source§impl Theme
impl Theme
pub fn light() -> Self
pub fn dark() -> Self
Sourcepub fn init(self, cx: &mut App)
pub fn init(self, cx: &mut App)
Install the theme as the app-global, replacing any existing one.
Sourcepub fn with_primary(self, color: impl Into<Hsla>) -> Self
pub fn with_primary(self, color: impl Into<Hsla>) -> Self
Override the primary accent color.
Sourcepub fn with_surface(self, color: impl Into<Hsla>) -> Self
pub fn with_surface(self, color: impl Into<Hsla>) -> Self
Override the raised-surface background.
Sourcepub fn with_surface_hover(self, color: impl Into<Hsla>) -> Self
pub fn with_surface_hover(self, color: impl Into<Hsla>) -> Self
Override the subtle hover/recessed fill.
Sourcepub fn with_dimmed(self, color: impl Into<Hsla>) -> Self
pub fn with_dimmed(self, color: impl Into<Hsla>) -> Self
Override the secondary/dimmed text color.
Sourcepub fn with_border(self, color: impl Into<Hsla>) -> Self
pub fn with_border(self, color: impl Into<Hsla>) -> Self
Override the default border/divider color.
pub fn spacing(&self, size: Size) -> f32
pub fn radius(&self, size: Size) -> f32
pub fn font_size(&self, size: Size) -> f32
Sourcepub fn primary_shade(&self) -> usize
pub fn primary_shade(&self) -> usize
The active primary-color shade for the current scheme.
Sourcepub fn surface_hover(&self) -> Color
pub fn surface_hover(&self) -> Color
A subtly recessed/hover fill.
Trait Implementations§
impl Global for Theme
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReadGlobal for Twhere
T: Global,
impl<T> ReadGlobal for Twhere
T: Global,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().