Skip to main content

dioxus_tw_components/components/
placeholder.rs

1use dioxus::prelude::*;
2
3#[derive(Clone, PartialEq, Props)]
4pub struct PlaceholderProps {
5    /// Additional attributes to apply to the element
6    #[props(extends = div, extends = GlobalAttributes)]
7    attributes: Vec<Attribute>,
8}
9
10#[component]
11pub fn Placeholder(mut props: PlaceholderProps) -> Element {
12    let default_classes = "placeholder";
13    crate::setup_class_attribute(&mut props.attributes, default_classes);
14
15    // Placeholders are fully animated by default
16    if !props
17        .attributes
18        .iter()
19        .any(|attr| attr.name == "data-animation")
20    {
21        props
22            .attributes
23            .push(Attribute::new("data-animation", "full", None, true));
24    }
25
26    rsx! {
27        div { ..props.attributes }
28    }
29}