Skip to main content

ThemeColors

Struct ThemeColors 

Source
pub struct ThemeColors {
Show 20 fields pub background: Hsla, pub foreground: Hsla, pub muted: Hsla, pub scrollbar: Hsla, pub surface: SurfaceColor, pub surface_secondary: Hsla, pub surface_tertiary: Hsla, pub overlay: SurfaceColor, pub segment: SurfaceColor, pub default: RoleColor, pub accent: RoleColor, pub success: RoleColor, pub warning: RoleColor, pub danger: RoleColor, pub field: FieldColors, pub border: Hsla, pub separator: Hsla, pub focus: Hsla, pub link: Hsla, pub backdrop: Hsla,
}
Expand description

All semantic tokens of one appearance.

Fields§

§background: Hsla

--background

§foreground: Hsla

--foreground

§muted: Hsla

--muted — de-emphasised body text and icons.

§scrollbar: Hsla

--scrollbar: var(--scrollbar-thumb)

§surface: SurfaceColor

--surface / --surface-foreground — non-floating components (cards, accordions, disclosure groups).

§surface_secondary: Hsla

--surface-secondary

§surface_tertiary: Hsla

--surface-tertiary

§overlay: SurfaceColor

--overlay / --overlay-foreground — floating components (tooltips, popovers, modals, menus).

§segment: SurfaceColor

--segment / --segment-foreground — selected segment of a segmented control (tabs, toggle groups).

§default: RoleColor

--default — the neutral backbone of the system.

§accent: RoleColor

--accent — the brand color (v2 primary).

§success: RoleColor

--success

§warning: RoleColor

--warning

§danger: RoleColor

--danger

§field: FieldColors§border: Hsla

--border

§separator: Hsla

--separator

§focus: Hsla

--focus

§link: Hsla

--link

§backdrop: Hsla

--backdrop — the scrim behind modals and drawers.

Implementations§

Source§

impl ThemeColors

Source

pub fn vibrant_palette(&self) -> bool

Whether [data-vibrant-palette="true"] is on (variables.css:317-330).

The flag lives on each RoleColor; the mixing roles are set together by crate::ThemeBuilder::vibrant_palette, so accent answers for all.

Source

pub fn set_vibrant_palette(&mut self, vibrant: bool)

Fans [data-vibrant-palette="true"] out over the roles the selector lists: accent, success, warning and danger. default is absent from both blocks upstream and keeps --default-soft-foreground.

Source

pub fn background_secondary(&self) -> Hsla

color-mix(in oklab, var(--background) 96%, var(--foreground) 4%)

Source

pub fn background_tertiary(&self) -> Hsla

color-mix(in oklab, var(--background) 92%, var(--foreground) 8%)

Source

pub fn background_inverse(&self) -> Hsla

--color-background-inverse: var(--foreground)

Source

pub fn separator_secondary(&self) -> Hsla

color-mix(in oklab, var(--surface) 85%, var(--surface-foreground) 15%)

Source

pub fn separator_tertiary(&self) -> Hsla

color-mix(in oklab, var(--surface) 81%, var(--surface-foreground) 19%)

Source

pub fn border_secondary(&self) -> Hsla

--border-secondary: color-mix(in oklab, var(--surface) 78%, var(--surface-foreground) 22%)

Source

pub fn border_tertiary(&self) -> Hsla

--border-tertiary: color-mix(in oklab, var(--surface) 66%, var(--surface-foreground) 34%)

Source

pub fn surface_secondary_foreground(&self) -> Hsla

--surface-secondary-foreground: var(--foreground)

v3 gives the secondary and tertiary surfaces their own foreground variables, both defaulting to the page’s, so a caller who repaints one of those surfaces has somewhere to put the matching text colour.

Source

pub fn surface_tertiary_foreground(&self) -> Hsla

--surface-tertiary-foreground: var(--foreground)

Source

pub fn role(&self, name: &str) -> &RoleColor

Resolves a role by its v3 token name, defaulting to accent.

Source

pub fn light() -> Self

Source

pub fn dark() -> Self

Trait Implementations§

Source§

impl Clone for ThemeColors

Source§

fn clone(&self) -> ThemeColors

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 ThemeColors

Source§

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

Formats the value using the given formatter. Read more

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<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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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