React Shimmer

用于 React.js 的异步加载、高性能图像组件。「🌠 Async loading, performant Image component for React.js」

Github星跟踪图

A powerful, customisable, <img> component that simulates a shimmer effect while loading. (with zero dependencies!) Currently compatible with React, but RN compatibility is also on the way.

Live Demo

Install

npm i react-shimmer

or

yarn add react-shimmer

Usage

import React from 'react'
import Image from 'react-shimmer'

function App(props) {
  return (
    <div>
      <Image
        src="https://example.com/test.jpg"
        width={640} height={480}
        style={{ objectFit: 'cover' }}
      />
    </div>
  )
}

or you can use the fallback prop:

import React from 'react'
import Image from 'react-shimmer'
import Spinner from './Spinner'

function App(props) {
  return (
    <div>
      <Image
        src="https://example.com/test.jpg"
        fallback={<Spinner />}
      />
    </div>
  )
}

Properties

Property, Type, Required, Default value, Description
:---, :---, :---, :---, :---
src, string, yes, color, string, no, #f6f7f8, Background color of the loader.
duration, number, no, 1600, Animation duration (ms) Higher value == slower animation.
width, number, yes (no if fallback is present), height, number, yes (no if fallback is present), style, object, no, onError, func, no, onLoad, func, no, fallback, React.Element, no, delay, number, no, Delay the starting time of the animation. (ms)

Contributing


Feel free to send PRs.

License

MIT © gokcan

主要指标

概览
名称与所有者gokcan/react-shimmer
主编程语言TypeScript
编程语言HTML (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2018-06-26 12:56:11
推送于2023-03-06 06:53:17
最后一次提交2022-01-29 02:03:25
发布数3
最新版本名称v3.1.3 (发布于 )
第一版名称v2.0.0 (发布于 )
用户参与
星数1.2k
关注者数15
派生数36
提交数151
已启用问题?
问题数25
打开的问题数1
拉请求数66
打开的拉请求数15
关闭的拉请求数16
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?