Skip to main content

Theme

Struct Theme 

Source
pub struct Theme {
Show 16 fields pub background: Color, pub surface: Color, pub text: Color, pub muted: Color, pub accent: Color, pub on_accent: Color, pub success: Color, pub warning: Color, pub danger: Color, pub type_scale: TypeScale, pub space: Scale, pub radius: Scale, pub shadow_sm: ShadowSpec, pub shadow_md: ShadowSpec, pub shadow_lg: ShadowSpec, pub motion: Motion,
}
Expand description

Colors, type, space, radii, shadows and motion for one look.

Fields§

§background: Color

Page background. Project::theme copies this onto the project.

§surface: Color

Cards and panels.

§text: Color

Primary text.

§muted: Color

Secondary text.

§accent: Color

Brand color, readable on the background.

§on_accent: Color

Text on top of the accent.

§success: Color

Positive.

§warning: Color

Caution.

§danger: Color

Failure.

§type_scale: TypeScale

Type roles.

§space: Scale

Padding, gap and margin, in pixels.

§radius: Scale

Corner radii, in pixels.

§shadow_sm: ShadowSpec

Shadows for Step::Sm, Step::Md and Step::Lg.

§shadow_md: ShadowSpec

Medium shadow.

§shadow_lg: ShadowSpec

Large shadow.

§motion: Motion

Durations and eases.

Implementations§

Source§

impl Theme

Source

pub fn dark() -> Theme

Near-black background, white text, blue accent. The project default.

Source

pub fn light() -> Theme

Off-white background, ink text.

Source

pub fn midnight() -> Theme

Blue-black, cool accent.

Source

pub fn paper() -> Theme

Warm paper and ink.

Source

pub fn vivid() -> Theme

Dark, with a strong accent and snappier motion.

Source

pub fn preset(name: &str) -> Option<Theme>

dark, light, midnight, paper or vivid.

Source

pub fn accent(self, color: Color) -> Theme

Rebuilds the accent (and the surface tint) from one brand color. The result stays at least 4.5:1 against the background.

Source

pub fn is_light(&self) -> bool

Whether the background is light (paper, light).

Source

pub fn ink(&self, ink: Ink) -> Color

The color of a role.

Source

pub fn space(&self, step: Step) -> f64

Padding, gap or margin for a step.

Source

pub fn radius(&self, step: Step) -> f64

Corner radius for a step.

Source

pub fn shadow(&self, step: Step) -> ShadowSpec

Shadow for a step. Xs uses the small shadow, Xl the large one.

Source

pub fn role(&self, role: TypeRole) -> TypeStyle

A type role. code is the monospace size; the family is set by .code().

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

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 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,