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

skeleton-styler

v5.0.6

Published

A lightweight TypeScript library to generate skeleton loading UIs with customizable styles and animations.

Readme

skeleton-styler

Playground Open in StackBlitz

A lightweight TypeScript library to generate skeleton loading UIs with customizable styles and animations.

Works with plain JavaScript, React, Vue, Angular, or any frontend framework.


Table of Contents


Installation

npm install skeleton-styler

or

yarn add skeleton-styler

Usage

Basic Example

import { ElementBuilder, SkeletonAnimation } from "skeleton-styler";

ElementBuilder.setConfigs({
  animation: SkeletonAnimation.Pulse,
  colors: ["#e0e0e0", "#c0c0c0"],
});

const skeleton = new ElementBuilder().setClass("skeleton").markAsSkeleton().generate();
document.body.appendChild(skeleton);

1. Vanilla HTML + JS

const app = document.getElementById("app");
const skeletonCard = new ElementBuilder()
  .s_flex()
  .append(...Array.from({ length: 3 }).map(() => new ElementBuilder().markAsSkeleton()));

app?.appendChild(skeletonCard.generate());

2. ReactJS

import React, { useState, useEffect, useRef } from "react";
import { SkeletonTemplate, ElementBuilder } from "skeleton-styler";

const skeletonInstance = SkeletonTemplate.UserAvatar({ r: 24, line: 2 });

const SkeletonWrapper = ({ loading, children, instance }) => {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (loading && el) {
      const skeleton = instance.generate();
      el.innerHTML = "";
      el.appendChild(skeleton);
    }
  }, [loading]);
  return loading ? <div ref={ref} /> : children;
};

export const MyComponent = () => {
  const [loading, setLoading] = useState(true);
  useEffect(() => {
    const timer = setTimeout(() => setLoading(false), 3000);
    return () => clearTimeout(timer);
  }, []);
  return (
    <SkeletonWrapper loading={loading} instance={skeletonInstance}>
      <div className="profile">
        <img src="/avatar.jpg" alt="User" width={48} height={48} />
        <p>Hello!</p>
      </div>
    </SkeletonWrapper>
  );
};

3. Angular

import { Component, ElementRef, Input, OnChanges, SimpleChanges } from '@angular/core';
import { ElementBuilder } from 'skeleton-styler';

@Component({
  selector: 'app-skeleton-wrapper',
  template: '<ng-content *ngIf="!loading"></ng-content>',
  standalone: true,
})
export class SkeletonWrapperComponent implements OnChanges {
  @Input() loading = false;
  @Input() instance!: ElementBuilder;

  constructor(private elRef: ElementRef<HTMLElement>) {}

  ngOnChanges(changes: SimpleChanges) {
    const container = this.elRef.nativeElement;
    if (this.loading && this.instance) {
      const skeleton = this.instance.generate();
      container.innerHTML = '';
      container.appendChild(skeleton);
    } else {
      container.innerHTML = '';
    }
  }
}

4. JSON Configuration Example (fromJSON)

import { ElementBuilder, SkeletonAnimation } from "skeleton-styler";

const jsonConfig = {
  skeleton: SkeletonAnimation.Progress,
  style: { display: "flex", flexDirection: "column", width: "100%" },
  children: [
    { skeleton: true, style: { width: "60px", height: "60px", borderRadius: "50%", margin: "8px" } },
    { skeleton: true, style: { width: "80%", height: "16px", margin: "8px 0" } },
  ],
};

const skeleton = ElementBuilder.fromJSON(jsonConfig);
document.body.appendChild(skeleton.generate());

🧩 SkeletonTemplate

SkeletonTemplate provides ready-to-use skeleton UI components — all powered by ElementBuilder.

Example

import { SkeletonTemplate } from "skeleton-styler";

const card = SkeletonTemplate.Card({ w: 320 });
document.body.appendChild(card.generate());

Common Templates

| Method | Description | | ------- | ------------ | | SkeletonTemplate.Line() | Simple text line skeleton | | SkeletonTemplate.Avatar() | Circular avatar skeleton | | SkeletonTemplate.UserAvatar() | Avatar with text lines | | SkeletonTemplate.Button() | Rounded button skeleton | | SkeletonTemplate.Card() | Image + text card skeleton | | SkeletonTemplate.Table() | Table layout skeleton | | SkeletonTemplate.Sidebar() | Sidebar placeholder |


Global Configuration

You can set default animation and colors globally using ElementBuilder:

ElementBuilder.setAnimation(SkeletonAnimation.Progress);
ElementBuilder.setColors(["#ccc", "#eee"]);
console.log(ElementBuilder.getConfigs());

| Method | Description | | ------- | ------------ | | setAnimation(animation) | Set default animation | | setColors(colors) | Set default skeleton colors | | setConfigs(config) | Apply multiple configs | | getConfigs() | Retrieve current config |


API Reference

StyleBuilder (commonly used)

| Method | Description | | ------- | ------------ | | s_flex() | Display flex | | s_w(v) | Set width | | s_h(v) | Set height | | s_m(v) | Margin | | s_p(v) | Padding | | s_bg(c) | Background color |

ElementBuilder

| Method | Description | | ------- | ------------ | | setTagName(tag) | Define HTML tag | | markAsSkeleton() | Mark element as skeleton | | append(...children) | Append child elements | | generate() | Generate HTMLElement | | fromJSON(config) | Build from JSON configuration |


License

MIT © 2026 Hoai Nam