Module dioxus

Source
Available on crate feature dio only.
Expand description

§🧬 Skeleton RS Dioxus Usage

Adding Skeleton RS to your project is simple:

  1. Make sure your project is set up with Dioxus. Refer to the Dioxus Getting Started Guide for setup instructions.

  2. Add the skeleton-rs library to your dependencies by including it in your Cargo.toml file:

    cargo add skeleton-rs --features=dio
  3. Import the Skeleton component into your Dioxus application.

§🛠️ Usage

Incorporating Skeleton RS into your Dioxus application is straightforward. Follow these steps:

  1. Import the Skeleton component into your Dioxus project:

    use dioxus::prelude::*;
    use skeleton_rs::dioxus::Skeleton;
    use skeleton_rs::{Variant, Animation, Direction, Theme};
  2. Use the Skeleton component within your Dioxus application:

    use dioxus::prelude::*;
    use skeleton_rs::dioxus::Skeleton;
    use skeleton_rs::Variant;
    
    #[component]
    fn App() -> Element {
        rsx! {
            Skeleton {
                variant: Variant::Text,
                width: "100%",
                height: "1.2em",
            }
        }
    }

§🔧 Props

PropertyTypeDescriptionDefault
variantVariantVisual variant: Text, Circle, Rect, etc.Text
animationAnimationAnimation style: Pulse, Wave, None.Pulse
directionDirectionAnimation direction: LeftToRight, RightToLeft, TopToBottom, etc.LeftToRight
themeThemeTheme for light/dark variants.Light
showboolManually control visibility of the skeleton.false
delay_msu32Delay before showing the skeleton in milliseconds.0
infer_sizeboolInfers width/height from child content if true.false
responsiveboolEnables scaling for responsive layouts.false
childrenElementContent to wrap in skeleton loading.None

§🎨 Styling Props

PropertyTypeDescriptionDefault
width&'static strWidth of the skeleton block."100%"
height&'static strHeight of the skeleton block."1em"
font_sizeOption<&str>Font size used for text variant.None
border_radius&'static strBorder radius for rounded shapes."4px"
line_height&'static strLine height of the skeleton block."1"
margin&'static strExternal margin styling.""
custom_style&'static strInline custom styles.""

§⚙️ Visibility Behavior

PropertyTypeDescriptionDefault
animate_on_hoverboolStarts animation on hover.false
animate_on_focusboolStarts animation on focus.false
animate_on_activeboolStarts animation on active interaction (e.g., click).false
animate_on_visibleboolUses IntersectionObserver to trigger animation when in view.false

§📏 Layout Constraints

PropertyTypeDescriptionDefault
max_widthOption<&str>Max width of the skeleton.None
min_widthOption<&str>Min width of the skeleton.None
max_heightOption<&str>Max height of the skeleton.None
min_heightOption<&str>Min height of the skeleton.None

§💡 Notes

  • The Skeleton component is ideal for loading states and placeholder UIs.
  • When animate_on_visible is enabled, IntersectionObserver is used to optimize performance.
  • Use the show prop to manually toggle visibility or let the component manage it.
  • Enable infer_size to make the skeleton size itself based on wrapped children.
  • For improved UX, use delay_ms to avoid flashing placeholders for fast-loading content.
  • Customize styles with custom_style and regular class/style props.

Structs§

SkeletonGroupProps
SkeletonProps
Properties for the Skeleton component.

Functions§

Skeleton
Skeleton Component
SkeletonGroup