黑白梦黑白梦

toggle navtoggle nav
  • 文章
  • 专栏
  • 文章
  • 专栏

react-content-loader 创建骨架屏占位符加载效果

发布于 2023-03-06, 更新于 2023-04-08

目录
安装用法

开箱即用,可定制,轻量级。

安装

https://www.npmjs.com/package/react-content-loader

npm install react-content-loader --save

用法

使用默认的渲染效果:

import ContentLoader from 'react-content-loader'

<ContentLoader />

使用预置的效果:

import { Facebook, Instagram, Code, List, BulletList } from 'react-content-loader'

<Facebook />
<Instagram />
<Code />
<List />
<BulletList />

传入自定义的 svg 元素渲染:

<ContentLoader viewBox="0 0 380 70">
    {/* Only SVG shapes */}    
    <rect x="0" y="0" rx="5" ry="5" width="70" height="70" />
    <rect x="80" y="17" rx="4" ry="4" width="300" height="13" />
    <rect x="80" y="40" rx="3" ry="3" width="250" height="10" />
</ContentLoader>
目录
安装用法
本文收录于专栏

一些好用的 npm 前端开源库

收集一些好用的前端开源库,主要是 npm 包

©2015-2026 黑白梦 粤ICP备15018165号

联系: heibaimeng@foxmail.com