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 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use crate::Link;
use leptos::*;
/// Injects an [`HTMLLinkElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement) into the document
/// head that loads a stylesheet from the URL given by the `href` property.
///
/// ```
/// use leptos::*;
/// use leptos_meta::*;
///
/// #[component]
/// fn MyApp() -> impl IntoView {
/// provide_meta_context();
///
/// view! {
/// <main>
/// <Stylesheet href="/style.css"/>
/// </main>
/// }
/// }
/// ```
#[component(transparent)]
pub fn Stylesheet(
/// The URL at which the stylesheet is located.
#[prop(into)]
href: String,
/// An ID for the stylesheet.
#[prop(optional, into)]
id: Option<String>,
/// Custom attributes.
#[prop(attrs, optional)]
attrs: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
if let Some(id) = id {
view! {
<Link id rel="stylesheet" href attrs/>
}
} else {
view! {
<Link rel="stylesheet" href attrs/>
}
}
}