React Shimmer

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

Github stars Tracking Chart

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

Main metrics

Overview
Name With Ownergokcan/react-shimmer
Primary LanguageTypeScript
Program languageHTML (Language Count: 4)
Platform
License:MIT License
所有者活动
Created At2018-06-26 12:56:11
Pushed At2023-03-06 06:53:17
Last Commit At2022-01-29 02:03:25
Release Count3
Last Release Namev3.1.3 (Posted on )
First Release Namev2.0.0 (Posted on )
用户参与
Stargazers Count1.2k
Watchers Count15
Fork Count36
Commits Count151
Has Issues Enabled
Issues Count25
Issue Open Count1
Pull Requests Count66
Pull Requests Open Count15
Pull Requests Close Count16
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private