3.2.0 • Published 2 years ago

react-shimmer v3.2.0

Weekly downloads
1,535
License
MIT
Repository
github
Last release
2 years ago

A powerful, customisable, Suspense-like <img> component that (optionally) simulates a shimmer effect while loading. (with zero dependencies!).

Live Demo

npm.io

Install

npm i react-shimmer

or

yarn add react-shimmer

Usage

import React from 'react'
import { Image, Shimmer } from 'react-shimmer'

function App() {
  return (
    <div>
      <Image
        src='https://source.unsplash.com/random/800x600'
        fallback={<Shimmer width={800} height={600} />}
      />
    </div>
  )
}
import React from 'react'
import { Image, Breathing } from 'react-shimmer'

function App() {
  return (
    <div>
      <Image
        src='https://source.unsplash.com/random/800x600'
        fallback={<Breathing width={800} height={600} />}
      />
    </div>
  )
}

or you can use your custom React component as a fallback:

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

PropertyTypeRequiredDefault valueDescription
srcstringyes
fallbackReactNodeyes
errorFallbackfuncno
onLoadfuncno
delaynumbernoDelay in milliseconds before showing the fallback
fadeInboolnofalseUse built-in fade animation on img
NativeImgPropsReact.ImgHTMLAttributesno

Contributing


Feel free to send PRs.

License

MIT © gokcan

3.2.0

2 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago