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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?