npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gridui/loading-surface

v1.3.1

Published

GridUI React loading surface

Readme

@gridui/loading-surface

Feedback family. Public API: LoadingSurface, Skeleton, SkeletonBox, SkeletonSuspense, their Props types, and skeleton configuration types.

Import components from @gridui/loading-surface and load @gridui/loading-surface/styles.css after Theme. Applications own routes, labels, state persistence, and branding.

See component ownership and release history.

Styles

Load Theme once. Use @gridui/loading-surface/styled for automatic component CSS in CSS-aware bundlers, or keep the CSS-free root import and load @gridui/loading-surface/styles.css. Both entries expose the same root API. The standalone stylesheet includes component dependency styles; Theme/reset remain separate. See the integration guide for static HTML loading, SSR limits, and avoiding duplicate CSS.

Loading surfaces

@gridui/loading-surface exports LoadingSurface and LoadingSurfaceProps. Its loading prop controls the breathing surface and aria-busy, defaulting to false. phase defaults to zero and maps finite integer positions into five repeating phases; fractions are truncated, negative positions wrap, and non-finite values use zero. CSS attributes select offsets as fractions of the shared duration, with no generated inline timing styles.

The component renders a div by default. asChild uses Radix Slot to compose classes, native props, events, and refs onto one React child. Custom children must forward these props to their surface. Keep loading attributes on the component rather than overriding them on the child. The ::after decoration is reserved for the surface and sits behind its content; it does not add padding, borders, dimensions, or interaction blocking.

<LoadingSurface loading={loading} phase={index} asChild>
    <GridItem padding={24}>
        <Metric label="Cases" value={loading ? "—" : cases} />
    </GridItem>
</LoadingSurface>

Theme tokens own --gridui-loading-duration, --gridui-loading-color, and minimum and maximum opacity. Reduced motion keeps a static low-opacity fill. Load @gridui/loading-surface/styles.css; animation requires no hydration. With hideContent, ready children fade in over the normal motion duration when mounted or revealed after loading, including completed empty and error states. There is no delay, layout movement, or numeric interpolation. Reduced motion reveals them immediately.

Applications own requests, localized status announcements, placeholder column content, and completion/error handling. LoadingSurface.hideContent hides children during loading while preserving their geometry. A display: contents visibility boundary encloses all content, including text returned by nested components, without adding a layout box. Its aria-hidden state follows loading so assistive technology hides and restores the same content. The loading boundary is inert and hides descendants with explicit visibility as well; ready content regains its ordinary focus and interaction behavior. The ready surface fades in as a whole so text nodes participate in the reveal. Native asChild cells remain direct children of their table row. Custom surfaces must forward children as well as surface props. DataTablePlaceholder owns inert, decorative placeholder rows with a configurable row count. Keep frame boundaries mounted while loading. An unknown amount of result content can still expand beyond its placeholder. An empty result or error is a completed state, not a continuing animation.

Measured skeletons

Skeleton measures its mounted children into text-line and media/control placeholders while loading is true. The same content subtree remains mounted through loading and reveal: state, refs, subscriptions, and Radix single-child composition keep their ordinary React lifetimes. Requests and sample data belong to the application:

import { Skeleton, SkeletonBox } from "@gridui/loading-surface";

<Skeleton loading={!profile} label="Loading profile">
    <ProfileCard profile={profile ?? SAMPLE_PROFILE} />
</Skeleton>
<SkeletonBox width="60%" height="1em" radius={2} />

Children must be renderable during loading. Use representative sample data for an initial request, and retained data during a refresh. Samples still mount and run effects; keep request and subscription owners outside sample presentations. Changing the child type or key still remounts it according to React's rules.

label supplies an optional loading status. Hidden content is inert and aria-hidden on the server as well as the client; the root owns aria-busy. fallback supplies a custom decorative skeleton instead of DOM measurement. It overlays the content and does not reserve additional layout space. Reserve dimensions yourself when no sample content exists.

The native div root accepts normal props and a ref. contentClassName and contentStyle customize the permanent content wrapper. For bounded scroll layouts, set fill on the skeleton and give its parent a definite height; the root and content wrapper become flex columns with min-height: 0. The scrolling child should use flex: 1; min-height: 0; overflow: auto. The component is a block boundary; put it inside a table cell, not between a table row and its cells.

Add data-skeleton-block to treat a custom avatar, badge, or chart as one block. Add data-skeleton-ignore to omit a subtree from measurement (it remains hidden with the loading content). Images, SVG, canvas, video, frames, native controls, and buttons are blocks automatically. Other containers preserve their text-line structure; background and shadow heuristics do not decide component semantics. Size images with width/height or aspect-ratio before they load.

Measurements follow content mutations, intrinsic sizes, fonts, window resizing, and nested scrolling. Rectangular overflow clipping and axis-aligned scaling are supported. Portals, shadow-root internals, pseudo-element content, rotated/skewed layouts, and virtualized offscreen content need explicit block hints or a custom fallback. Trees beyond the measurement budget use one covering block.

Before JavaScript, the loading region is a surface placeholder with the sample layout; hydration refines it into measured shapes. Ready server-rendered content is visible immediately. No inline boot script, data fetching, or persistent DOM cache is used. A sample cannot predict unknown row counts or text lengths, so different loaded geometry can still cause layout shift.

Appearance and reveal

Skeleton and SkeletonBox accept animation and speed:

| Animation | Behavior | | --- | --- | | pulse (default) | Opacity pulse synchronized to the document timeline | | shimmer | A shared viewport-aligned diagonal highlight across separate boundaries | | group-shimmer | A highlight sized to each boundary | | none | Static placeholders |

speed is slow (the loading duration token) or fast (65% of that duration). Light/dark/system appearance comes from GridUI Theme; there is no second theme provider. Color and duration use existing loading tokens. Local overrides are --gridui-skeleton-color, --gridui-skeleton-highlight, and --gridui-skeleton-radius; radius also sets the radius override. A SkeletonBox inside a skeleton inherits its appearance unless given its own animation.

reveal controls the transition after loading becomes false:

| Reveal | Behavior | | --- | --- | | together | Crossfade the skeleton and content together | | sequence | Reveal existing text/media elements and fade bones in screen order; offscreen pieces settle immediately | | sweep | A diagonal mask reveals content and removes the skeleton with the inverse mask | | smart (default) | Suppress fast loading flashes, settle during active input, use a short refresh fade, and sequence larger first loads | | SkeletonRevealSpec | Custom order, delay, duration, entrance transform/filter, mask, and context-based selection |

delay controls when the skeleton appears after loading starts: 150 ms for smart, zero otherwise. During a delayed refresh the retained content stays visible but inert; during an initial delay its layout remains reserved. Loads that finish within the delay show no animated skeleton. Server HTML still has a surface placeholder before hydration; framework boot scripts are not required.

onReveal runs once when a loading cycle reaches ready, including immediate reveals. An interrupted reveal does not report completion. The same content tree remains mounted across every mode. Animated completion clears masks and animation objects. Reduced motion always makes reveals immediate, including changes to the preference during an active transition.

<Skeleton loading={loading} animation="shimmer" reveal="sequence" onReveal={onReady}>
    <ProfileCard profile={profile ?? SAMPLE_PROFILE} />
</Skeleton>
<Skeleton loading={loading} reveal={{
    duration: 240,
    order: (piece) => Math.max(0, piece.y),
    enter: { transform: "translateY(6px)", filter: "blur(2px)" },
    choose: (context) => ({ duration: context.refresh ? 100 : 240 }),
}}>
    {children}
</Skeleton>

Custom order returns a delay in milliseconds, or null for immediate visibility. SkeletonRevealPiece provides geometry relative to the boundary and an index. choose runs once with size, piece count, time spent showing the skeleton, refresh status, and recent-input status. Its returned fields override the spec. Timings must be finite and nonnegative and are capped at 1000 ms per field. wipe.mask(progress, context) returns a CSS mask-image; wipe.out optionally provides the outgoing mask. Otherwise its inverse is used. Custom callbacks must be pure. Entrance properties deliberately exclude layout-affecting styles.

Sequences and wipes fall back to an overall crossfade beyond 200 pieces. Wipes also fall back for large viewport areas or unsupported CSS mask composition; a stalled frame loop settles immediately. These bounds prevent complex samples from making the loading UI more expensive than the content.

Fonts, images, and diagnostics

text={{ top: "cap-height", bottom: "baseline" }} aligns bars with measured font metrics. Top choices are ascender (default), cap-height, and x-height; bottom choices are descender (default) and baseline. Font-load events trigger new measurements. A proportional estimate is used when canvas metrics are absent.

By default, waitForImages covers images independently until they load and decode, then reveals each image without holding back ready text. Errors release the cover; the host owns error presentation. Source changes restart readiness, detached images are cleaned up, and decode promises cannot update disposed boundaries. Use waitForImages={false} when an image component owns its loading presentation. Images still require reserved dimensions; lazy images must enter the viewport to load. Nested skeletons own their own images.

debug outlines measured shapes and shows the source layout through them. onDiagnostics receives rectangle count, measurement-budget status, unsized-image count, and layout-shift score attributed to this boundary. Layout-shift observation runs only for debug/diagnostic consumers when the browser supports it. No source text, image URL, DOM snapshot, or application data is logged or persisted.

React Suspense

<SkeletonSuspense sample={<ProfileCard profile={SAMPLE_PROFILE} />}
    skeletonProps={{ animation: "shimmer", label: "Loading profile" }}>
    <AsyncProfile />
</SkeletonSuspense>

The sample must not suspend. This adapter gives React a measured fallback and leaves the real subtree to React Suspense. React replaces the fallback on resolution; it does not crossfade two committed trees or preserve state of an uncommitted suspended render. Use controlled Skeleton.loading for retained content and all reveal strategies. Streaming, request caches, and error boundaries remain host-owned.

Reference capability mapping

The React UI capabilities studied in Skullet map to GridUI as follows. The API is intentionally owned by this package.

| Reference capability | GridUI contract | | --- | --- | | Appearance and named/custom reveals | animation, speed, reveal, delay | | Typography and image readiness | text, waitForImages | | Explicit shapes and component overrides | SkeletonBox, fallback, block/ignore hints; no recursive React cloning or static component mutation | | Sample/retained data | Host renders the same component with sample or retained props | | React Suspense | SkeletonSuspense with an explicit sample | | Theme modes | Existing GridUI Theme | | Debug and reveal notification | debug, onDiagnostics, onReveal | | Last/session/persistent snapshots | Host-owned data retention; no browser-storage or DOM-cache modes | | Fetching/error/empty policies | Host-owned completed content; set loading={false} | | Pre-paint boot scripts, CSP nonce, multi-framework adapters | Host/framework integration; omitted from this React family |

LoadingSurface remains the lightweight surface treatment; use Skeleton when content-shaped placeholders are needed. All public components own their own source directories. Appearance code is shared by the two real skeleton consumers; measurement, image readiness, reveal planning, animation execution, and React lifecycle remain separate collaborators inside src/skeleton/.

Component reference contains focused API pages for each public component.

Shared animation policy and tempo come from MotionConfig in @gridui/motion. Disabled or reduced-motion policy settles decoration without disabling interaction. See the motion guide for CSS scopes, portal behavior, and specialized timing contracts.

Sizing and density

Skeleton follows actual rendered geometry, including size changes in observed controls. SkeletonBox retains explicit width/height. There is no copied control-size or density scale on loading wrappers.

See the shared sizing contract for native attributes, scope precedence, tokens and target behavior.