zng_wgt/
color_props.rs

1use zng_color::{
2    COLOR_SCHEME_VAR,
3    colors::{ACCENT_COLOR_VAR, BASE_COLOR_VAR},
4};
5
6use crate::prelude::*;
7
8/// Defines the preferred color scheme in the widget and descendants.
9///
10/// Sets the [`COLOR_SCHEME_VAR`].
11#[property(CONTEXT, default(COLOR_SCHEME_VAR))]
12pub fn color_scheme(child: impl UiNode, pref: impl IntoVar<ColorScheme>) -> impl UiNode {
13    with_context_var(child, COLOR_SCHEME_VAR, pref)
14}
15
16/// Defines the preferred accent color in the widget and descendants.
17///
18/// The is a distinct background/fill color that contrasts with the foreground text color.
19///
20/// Sets the [`COLOR_SCHEME_VAR`].
21#[property(CONTEXT, default(ACCENT_COLOR_VAR))]
22pub fn accent_color(child: impl UiNode, color: impl IntoVar<LightDark>) -> impl UiNode {
23    with_context_var(child, ACCENT_COLOR_VAR, color)
24}
25
26/// Defines the seed color used by widgets to derive background, non active border.
27///
28/// Usually the color is used directly for background fill and highlighted for others.
29#[property(CONTEXT, default(BASE_COLOR_VAR))]
30pub fn base_color(child: impl UiNode, color: impl IntoVar<LightDark>) -> impl UiNode {
31    with_context_var(child, BASE_COLOR_VAR, color)
32}