Skip to main content

adam_web_ui/components/
theme.rs

1//! Shared control styling.
2//!
3//! Wrap each independent Dioxus root in [`Theme`].
4use dioxus::prelude::*;
5
6include!(concat!(env!("OUT_DIR"), "/theme-styles.rs"));
7
8/// Installs reusable component tokens and wraps children in a theme scope.
9///
10/// The immutable stylesheet is embedded, not a consumer-relative URL.
11/// The document-owned installer deduplicates styles across independent roots;
12/// unmounting one wrapper does not remove another root's styles.
13/// The renderer supplies Dioxus's `Document` context; missing context reports
14/// a stylesheet-delivery failure on the platform diagnostic channel.
15///
16/// # Examples
17/// ```
18/// use adam_web_ui::components::Theme;
19/// use dioxus::prelude::*;
20/// fn app() -> Element { rsx! { Theme { p { "Content" } } } }
21/// ```
22#[component]
23pub fn Theme(children: Element) -> Element {
24    super::styles::use_control_styles();
25    rsx! {
26        div { class: "{Styles::adam_theme} adam-theme", {children} }
27    }
28}