zino_dioxus/theme/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! UI themes for components.

use self::Theme::*;
use std::fmt;

/// A theme is a set of configurations controlling a component's styles and default props.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum Theme {
    #[default]
    /// The `Light` theme.
    Light,
    /// The `Dark` theme.
    Dark,
    /// A custom theme.
    Custom(&'static str),
}

impl fmt::Display for Theme {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let theme = match self {
            Light => "light",
            Dark => "dark",
            Custom(name) => name,
        };
        write!(f, "{theme}")
    }
}