0.1.2 • Published 3 years ago

react-simple-placeholder-image v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Simple Placeholder Image

A Minimal lightweight react component for adding a nice image placeholder.

NPM JavaScript Style Guidenpm bundle sizeGitHub

Install

npm

npm i react-simple-placeholder-image

Yarn

yarn add react-simple-placeholder-image

Examples

import React from 'react'
import { DummyImage } from 'react-simple-placeholder-image'

const MyComponent = () => {
  return (
    <div className='App'>
      <DummyImage width={500} height={500} />
      <DummyImage width={500} height={500} placeholder='Hello World!' />
      <DummyImage width={500} height={500} shape='image' />
      <DummyImage width={500} height={500} shape='avatar' />
      <DummyImage width={500} height={500} placeholder='Colored!' bgColor='#0a1929' fgColor='#eb0014' />
    </div>
  )
}

Component

import React from 'react'
import { DummyImage } from 'react-simple-placeholder-image'

const MyComponent = () => {
  return (
    <div className='App'>
      <DummyImage {/* Props */} />
    </div>
  )
}

Component Props

PropTypeOptionsDescriptionDefault
shapeavatar \| image \| textOptionalImage shape styletext
widthNumberOptionalImage width300
heightNumberOptionalImage height300
bgColorStringOptionalImage background color#e5e5e5
fgColorStringOptionalImage foreground color#f9f9f9
placeholderStringOptionalText placeholderwidth x height
fontFamilyStringOptionalText font familysans-serif
styleReact.CSSPropertiesOptionalCSS style propmaxWidth: '100%', height: 'auto'
classNameStringOptionalclassName propdummy-img
altStringOptionalAlt propdummy-img

Hook

import React from 'react'
import { useDummyImage } from 'react-simple-placeholder-image'

const MyComponent = () => {
  const image = useDummyImage({
    /* Config */
  })

  return (
    <div className='App'>
      ...
      <img src={image} alt='dummy-img' />
      ...
    </div>
  )
}

Hook Config

PropTypeOptionsDescriptionDefault
shapeavatar \| image \| textOptionalImage shape styletext
widthNumberOptionalImage width300
heightNumberOptionalImage height300
bgColorStringOptionalImage background color#e5e5e5
fgColorStringOptionalImage foreground color#f9f9f9
placeholderStringOptionalText placeholderwidth x height
fontFamilyStringOptionalText font familysans-serif

Edit react-simple-placeholder-image

License

MIT © awran5