diff --git a/packages/document/src/document.rs b/packages/document/src/document.rs index 822f149565..08320f6f3c 100644 --- a/packages/document/src/document.rs +++ b/packages/document/src/document.rs @@ -105,6 +105,7 @@ pub trait Document: 'static { // The style has a src, render it as a link tag (Some(_), _) => { attributes.push(("type", "text/css".into())); + attributes.push(("rel", "stylesheet".into())); self.create_head_element("link", &attributes, None) } // The style has neither contents nor src, log an error diff --git a/packages/document/src/elements/mod.rs b/packages/document/src/elements/mod.rs index e9fbbc4a46..9f0d614225 100644 --- a/packages/document/src/elements/mod.rs +++ b/packages/document/src/elements/mod.rs @@ -7,8 +7,6 @@ use dioxus_core_macro::*; mod link; pub use link::*; -mod stylesheet; -pub use stylesheet::*; mod meta; pub use meta::*; mod script; diff --git a/packages/document/src/elements/style.rs b/packages/document/src/elements/style.rs index bb2f682153..9b6da22937 100644 --- a/packages/document/src/elements/style.rs +++ b/packages/document/src/elements/style.rs @@ -39,7 +39,7 @@ impl StyleProps { } } -/// Render a [`style`](crate::elements::style) tag into the head of the page. +/// Render a [`style`](crate::elements::style) or [`link`](crate::elements::link) tag into the head of the page. /// /// If present, the children of the style component must be a single static or formatted string. If there are more children or the children contain components, conditionals, loops, or fragments, the style will not be added. /// @@ -57,6 +57,10 @@ impl StyleProps { /// }} /// "# /// } +/// // You could also use a style with a href to load a stylesheet asset +/// document::Style { +/// href: asset!("/assets/style.css") +/// } /// } /// } /// ``` diff --git a/packages/document/src/elements/stylesheet.rs b/packages/document/src/elements/stylesheet.rs deleted file mode 100644 index 30e5893e14..0000000000 --- a/packages/document/src/elements/stylesheet.rs +++ /dev/null @@ -1,31 +0,0 @@ -use super::*; - -/// Render a [`link`](crate::elements::link) tag into the head of the page with the stylesheet rel. -/// This is equivalent to the [`Link`](crate::Link) component with a slightly more ergonomic API. -/// -/// -/// # Example -/// ```rust -/// # use dioxus::prelude::*; -/// fn RedBackground() -> Element { -/// rsx! { -/// document::Stylesheet { -/// href: asset!("/assets/style.css") -/// } -/// } -/// } -/// ``` -/// -///
-/// -/// Any updates to the props after the first render will not be reflected in the head. -/// -///
-#[component] -pub fn Stylesheet(props: LinkProps) -> Element { - super::Link(LinkProps { - rel: Some("stylesheet".into()), - r#type: Some("text/css".into()), - ..props - }) -}