@daysmart/angular-skeleton-screen

中文文档
1.0.1发布于 2025/11/20TypeScriptES Module近 30 天下载 2513

npm downloads [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@daysmart/angular-skeleton-scree

原始使用文档
文档目录11 节
  1. Step 1 - Import the SkeletonScreenModule
  2. Step 2 - Add the skeleton screen's style sheet to your glob…
  3. Directives
  4. skeletonScreen
  5. skeletonData
  6. skeletonTable
  7. Supported Inputs
  8. Other Notes
  9. Example
  10. Sample Template
  11. Sample Component

npm downloads npm bundle size (minified + gzip)

Setup

Step 1 - Import the SkeletonScreenModule

Add the SkeletonScreenModule to your application module so that the skeleton directives will be accessible.

...
import { SkeletonScreenModule } from '@daysmart/angular-skeleton-screen';
...

@NgModule({
  declarations: [
    SomeComponent
  ],
  imports: [
    ...
    SkeletonScreenModule,
    ...
  ],
  providers: []
})
export class SomeModule {}

Step 2 - Add the skeleton screen's style sheet to your global stylesheet list

Add the skeleton-screen.scss file to the list of your global stylesheets in your angular.json file.

{
    "projects": {
        "some-angular-proj": {
            "architect": {
                "build": {
                    "options": {
                        "styles": [
                            "node_modules/@daysmart/angular-skeleton-screen/styles/skeleton-screen.scss"
                        ]
                    }
                }
            }
        }
    }
}

Usage

Directives

skeletonScreen

Apply this to the top most container of the skeleton screen you'll be configuring. Any inputs set on it are propagated down to it's child skeleton directives and act as defaults. This acts as a wrapper for the skeletonData and skeletonTable directives and is not actually required in order to use these. It just makes life a lot easier on a larger skeleton screen.

skeletonData

Apply this to any element you want to have replaced with a piece of the skeleton screen. It will get it's defaults from the parent skeletonScreen directive but can be set up independently of one. You can override the defaults by setting the same inputs on the skeletonData element itself.

skeletonTable

Apply this to any element you want to have replaced with a piece of the skeleton screen. It will get it's defaults from the parent skeletonScreen directive but can be set up independently of one. You can override the defaults by setting the same inputs on the skeletonTable element itself.

Supported Inputs

  1. showSkeleton - When set to a non-falsy value, the skeleton will be shown. This is supported by all directives and can be overridden by all child directives.
  2. placeholderHeight - Can be set to a number or string or left unset. When set to a number it unit defaults to px. A unit can be provided when a string is used. When left blank, the directive will try its best to infer the height of the original element and use that. This is supported by all directives and can be overridden by all child directives.
  3. placeholderWidth - Can be set to a number or string or left unset. When set to a number it unit defaults to px. A unit can be provided when a string is used. When left blank, the directive will try its best to infer the width of the original element and use that. This is only supported by the skeletonScreen and skeletonData directives.
  4. skeletonTableRowAmount - Takes in a number that represents the amount of skeleton rows to show within the skeleton table. This is only supported by the skeletonScreen and skeletonTable directives.

Other Notes

  • These directives can be applied to material components as well.
  • The skeletonData directive cannot be applied directly to self-enclosed elements (img, input, etc). If you need to apply the directive to an element like this, it must be applied to a wrapper element such as a div or span.

Example

Sample Template

<div
    class="info-container"
    skeletonScreen
    [showSkeleton]="isLoading"
    placeholderWidth="50%"
>
    <!-- The skeletonScreen's placeholderWidth is being overridden-->
    <span skeletonData placeholderWidth="5rem" placeholderHeight="5rem">
        <!-- The skeletonData directive does not support being applied directly to an img element -->
        <img [src]="profile.imgSrc" />
    </span>

    <!--No placeholder height, so the directive attempts to infer the correct size-->
    <!-- All the defaults set by the skeleton are being used -->
    <div class="field-container" skeletonData>
        Name:
        <span name="name">{{ profile.name }}</span>
    </div>

    <!-- The skeletonScreen's showSkeleton is being overridden-->
    <table
        skeletonTable
        [skeletonTableRowAmount]="5"
        [showSkeleton]="tableIsLoading"
    >
        ...
    </table>
</div>

Sample Component

@Component({
    ...
})
export class SomeComponent implements OnInit {
    isLoading: boolean;
    profile: SomeProfile;

    constructor(
        private httpClient: SomeHttpClient
    )

    ngOnInit() {
        this.httpClient.getProfile(...)
            .pipe(
                map(profile => {
                    this.isLoading = false;
                    this.profile = profile;
                })
            );
    }

    ...
}

版本与发布记录

@daysmart/angular-skeleton-screen 共发布 25 个版本,首次发布于 2020/09/24;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.1latest2025/11/2011 个月前
1.0.02024/08/022 年前
0.1.02021/11/184 年前
0.0.222021/02/105 年前
0.0.212021/01/305 年前
0.0.202021/01/305 年前

关于 @daysmart/angular-skeleton-screen 的常见问题

@daysmart/angular-skeleton-screen 是什么?

[![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@daysmart/angular-skeleton-scree

如何安装 @daysmart/angular-skeleton-screen?

在项目目录运行 npm install @daysmart/angular-skeleton-screen,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/core(>=16)、@angular/common(>=16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@daysmart/angular-skeleton-screen 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@daysmart/angular-skeleton-screen 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@daysmart/angular-skeleton-screen 可以商用吗?

@daysmart/angular-skeleton-screen 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@daysmart/angular-skeleton-screen 的下载量有多少?

根据 npm 官方下载统计,@daysmart/angular-skeleton-screen 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,513 次,日均约 84 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@daysmart/angular-skeleton-screen 还在维护吗?

最新版本 1.0.1 发布于 2025/11/20(11 个月前);至今共发布 25 个版本,其中过去 12 个月发布了 1 个;首次发布于 2020/09/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。