Skip to content
PorabuildHeroGPUI component library
v0.14.0 ยท Apache-2.0

Feedback

Skeleton

A placeholder shimmer shown while content loads.

Rust
use herogpui::components::skeleton::Skeleton;

Skeleton on docs.rsSource at v0.14.0

Usage

Showing Usage, live: HeroGPUI compiled to WebAssembly. The canvas has no accessibility tree; each example's description and code below carry the same information.

Usage

An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children(vec![gpui::div()
        .w(px(250.))
        .flex()
        .flex_col()
        .gap(px(20.))
        .child(Skeleton::new().w(px(218.)).h(px(128.)).radius(px(8.)))
        .child(
            gpui::div()
                .flex()
                .flex_col()
                .gap(px(12.))
                .child(Skeleton::new().w(px(130.)).h(px(12.)))
                .child(Skeleton::new().w(px(174.)).h(px(12.)))
                .child(Skeleton::new().w(px(87.)).h(px(12.))),
        )
        .into_any_element()])

Text Content

An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children(vec![gpui::div()
        .w(px(420.))
        .flex()
        .flex_col()
        .gap(px(12.))
        .children(
            [1.0_f32, 0.83, 0.66, 1.0, 0.5]
                .into_iter()
                .map(|f| Skeleton::new().w(px(420. * f)).h(px(16.))),
        )
        .into_any_element()])

User Profile

Runs in a view's render: self is the view holding this example's state and cx is its Context<Self>.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children(vec![gpui::div()
        .flex()
        .items_center()
        .gap(px(12.))
        // v3 rounds this one with `rounded-full`. A clipping
        // wrapper does not round it on vanilla GPUI (the clip
        // is rectangular), so the skeleton carries the radius
        // itself: half its size is `rounded-full`.
        .child(
            gpui::div()
                .flex_shrink_0()
                .child(Skeleton::new().w(px(40.)).h(px(40.)).radius(px(20.))),
        )
        .child(
            gpui::div()
                .flex()
                .flex_col()
                .gap(px(8.))
                .child(Skeleton::new().w(px(144.)).h(px(12.)))
                .child(Skeleton::new().w(px(96.)).h(px(12.))),
        )
        .into_any_element()])

List Items

An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children((0..3)
        .map(|_| {
            gpui::div()
                .flex()
                .items_center()
                .gap(px(12.))
                .child(Skeleton::new().w(px(40.)).h(px(40.)))
                .child(
                    gpui::div()
                        .flex()
                        .flex_col()
                        .gap(px(8.))
                        .child(Skeleton::new().w(px(320.)).h(px(12.)))
                        .child(Skeleton::new().w(px(256.)).h(px(12.))),
                )
        }))

Grid

An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children(vec![gpui::div()
        .flex()
        .flex_wrap()
        .gap(px(16.))
        .children((0..6).map(|_| Skeleton::new().w(px(130.)).h(px(96.))))
        .into_any_element()])

Single Shimmer

One shimmer runs across a whole group: the animation sits on the parent and is turned off on each child. An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children(vec![
        Skeleton::new()
            .w(px(422.))
            .h(px(96.))
            .animation_type(herogpui::theme::SkeletonAnimation::Shimmer)
            .child(
                gpui::div()
                    .flex()
                    .gap(px(16.))
                    .children((0..3).map(|_| {
                        Skeleton::new()
                            .w(px(130.))
                            .h(px(96.))
                            .animation_type(herogpui::theme::SkeletonAnimation::None)
                    })),
            )
            .into_any_element(),
    ])

Animation Types

An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_wrap()
    .items_center()
    .justify_center()
    .gap(px(12.))
    .children(vec![
        Skeleton::new()
            .w(px(160.))
            .h(px(80.))
            .animation_type(herogpui::theme::SkeletonAnimation::Shimmer)
            .into_any_element(),
        Skeleton::new()
            .w(px(160.))
            .h(px(80.))
            .animation_type(herogpui::theme::SkeletonAnimation::Pulse)
            .into_any_element(),
        Skeleton::new()
            .w(px(160.))
            .h(px(80.))
            .animation_type(herogpui::theme::SkeletonAnimation::None)
            .into_any_element(),
    ])

Loading

An element expression with window: &mut Window and cx: &mut App in scope.

Rust
use herogpui::prelude::Skeleton;
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
use herogpui::gpui;

gpui::div()
    .flex()
    .flex_col()
    .items_start()
    .justify_center()
    .gap(px(12.))
    .children(vec![
        Skeleton::new().w(px(320.)).h(px(16.)).into_any_element(),
        Skeleton::new().w(px(260.)).h(px(16.)).into_any_element(),
        Skeleton::new().w(px(180.)).h(px(16.)).into_any_element(),
    ])

Anatomy

Rust types

Skeleton

Skeleton is assembled from these builders. The API reference lists each one.

API reference

Against HeroUI v3.2.6: 5 entries ported, 0 partial, 1 not ported. Partial rows are marked in the tables; entries not ported are listed under each table with the reason.

Builders

Skeleton builders
BuilderValuesDefaultDescription
animation_type(SkeletonAnimation)SkeletonAnimation::Shimmer | SkeletonAnimation::Pulse | SkeletonAnimation::NoneSkeletonAnimation::ThemeSelects shimmer, pulse, or no animation; theme token supplies the default.
Not ported1 HeroUI entry not ported
Skeleton builders not ported
HeroUI v3Why it is not ported
Skeleton.classNameBrowser styles are unavailable.

Parts

Skeleton parts
PartDescription
SkeletonClipped placeholder surface with optional hidden layout content.

States

Skeleton states
StateBuilderDescription
ShimmerSkeletonAnimation::ShimmerA highlight band sweeps across the placeholder.
PulseSkeletonAnimation::PulseThe placeholder opacity pulses.
No animationSkeletonAnimation::NoneA static placeholder is rendered, including when reduced motion is requested.