Skip to main content

dioxus_docs_kit/components/
theme_toggle.rs

1use dioxus::prelude::*;
2
3use super::shared::ThemeToggleButton;
4use crate::registry::DocsRegistry;
5
6/// Light/dark theme toggle button.
7///
8/// Reads theme configuration from `DocsRegistry` context and current theme from
9/// the [`CurrentTheme`](super::docs_layout::CurrentTheme) context (provided by
10/// `DocsLayout` or [`use_theme_provider`](super::shared::use_theme_provider)).
11///
12/// Renders nothing if the registry has no `toggle_themes` configured.
13#[component]
14pub fn ThemeToggle() -> Element {
15    let registry = use_context::<&'static DocsRegistry>();
16
17    rsx! {
18        ThemeToggleButton { theme: registry.theme.clone() }
19    }
20}