dark_light/lib.rs
1//! This crate is designed to facilitate the development of applications that support both light and dark themes. It provides a simple API to detect the current theme mode.
2//!
3//! It supports macOS, Windows, Linux, BSDs, and WASM.
4//!
5//! On Linux the [XDG Desktop Portal](https://flatpak.github.io/xdg-desktop-portal/) D-Bus API is checked for the `color-scheme` preference, which works in Flatpak sandboxes without needing filesystem access.
6
7mod error;
8mod mode;
9mod platforms;
10
11pub use error::Error;
12pub use mode::Mode;
13
14/// Detects the system theme mode.
15///
16/// # Example
17///
18/// ``` no_run
19/// use dark_light::{ Error, Mode };
20///
21/// fn main() -> Result<(), Error> {
22/// let mode = dark_light::detect()?;
23/// match mode {
24/// Mode::Dark => {},
25/// Mode::Light => {},
26/// Mode::Unspecified => {},
27/// }
28/// Ok(())
29/// }
30/// ```
31pub use platforms::platform::detect;