#[non_exhaustive]pub struct Theme {Show 18 fields
pub background: Rgba,
pub surface: Rgba,
pub surface_raised: Rgba,
pub sunken: Rgba,
pub text: Rgba,
pub text_muted: Rgba,
pub accent: Rgba,
pub accent_text: Rgba,
pub border: Rgba,
pub selection: Rgba,
pub hover: Rgba,
pub danger: Rgba,
pub warning: Rgba,
pub success: Rgba,
pub done: Rgba,
pub link: Rgba,
pub scrollbar: Rgba,
pub focus: Rgba,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.background: RgbaWindow, editor, and panel background (visuals.panel_fill).
surface: RgbaRaised chrome: menus, dialogs, the sidebar, the tab strip (visuals.window_fill).
surface_raised: RgbaA second raised surface for cards.
sunken: RgbaSunken surfaces: text fields, steppers, segmented controls (extreme_bg_color).
text: RgbaPrimary text.
text_muted: RgbaSecondary text: hints, descriptions, inactive tabs.
accent: RgbaBrand accent.
accent_text: RgbaText drawn on the accent.
border: RgbaBorders and separators.
selection: RgbaSelection background: selected rows, active segments, primary buttons.
hover: RgbaHover background for rows and icon buttons.
danger: RgbaErrors and destructive actions.
warning: RgbaWarnings and conflict banners.
success: RgbaSuccess messages.
done: Rgba“Done” purple.
link: RgbaHyperlinks.
scrollbar: RgbaScrollbar handle.
focus: RgbaKeyboard focus ring, hovered borders, and the active-row marker.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn high_contrast(self) -> Self
pub fn high_contrast(self) -> Self
A high-contrast variant of this theme: pure black or white surfaces, maximum text contrast, stronger borders, and a readable brand accent.
Sourcepub fn ensure_aa(self) -> Self
pub fn ensure_aa(self) -> Self
Adjust text and accent pairs until they reach WCAG AA (4.5:1 for text, 3:1 for large text and controls), preserving the theme’s light/dark polarity.
Sourcepub fn to_css_variables(&self) -> String
pub fn to_css_variables(&self) -> String
The theme as #rrggbb CSS custom properties.
Sourcepub fn from_vscode_json(text: &str) -> Result<Self, ThemeImportError>
Available on crate feature serde only.
pub fn from_vscode_json(text: &str) -> Result<Self, ThemeImportError>
serde only.Import a VS Code color theme (colors object); syntax token colors are accepted
but do not replace the workbench tokens.
§Errors
When the JSON is malformed or lacks editor.background and foreground.
Source§impl Theme
impl Theme
Sourcepub fn with_accent(self, accent: Rgba) -> Self
pub fn with_accent(self, accent: Rgba) -> Self
The same tokens with a new brand color: accent, focus, link, selection,
and accent_text are derived from it so they keep AA contrast on this base.
use crisol_core::color::Rgba;
use crisol_core::theme::{Theme, contrast_ratio};
let brand = Theme::dark().with_accent(Rgba::from_rgb(0xe0, 0x6c, 0x2b));
assert!(contrast_ratio(brand.link, brand.background) >= 4.5);
assert!(contrast_ratio(brand.accent_text, brand.accent) >= 4.5);Sourcepub fn accessibility_issues(&self) -> Vec<(&'static str, f32)>
pub fn accessibility_issues(&self) -> Vec<(&'static str, f32)>
The pairs that miss WCAG AA (4.5:1 for text, 3:1 for the focus ring), with their ratio. Empty for every built-in theme; check your own themes with it.
Trait Implementations§
impl Copy for Theme
Source§impl<'de> Deserialize<'de> for Theme
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Theme
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Theme
impl StructuralPartialEq for Theme
Auto Trait Implementations§
impl Forget for Theme
impl Freeze for Theme
impl Move 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§
impl<T> Allocation for T
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 more