2.0.1 • Published 2 years ago

react-fitted-img v2.0.1

Weekly downloads
76
License
MIT
Repository
github
Last release
2 years ago

react-fitted-img

React component for fitting and positioning images with cross-browser support.

Usage

import FittedImg from 'react-fitted-img';

<FittedImg src="/path/to/image.png" alt="Thing" fit="cover" position="0 50%" />;

Props

  • src required URL of the image you want to embed (MDN)
  • alt optional text description of the image (MDN)
  • fit optional sets how the image should be resized to fit its container. Supports the object-fit values: fill (default), contain, cover, and none.
  • height optional the intrinsic height of the image in pixels. (MDN)
  • position optional the alignment of the image's contents within the element's box. Supports object-position values.
  • width optional the intrinsic width of the image in pixels. (MDN)

:information_source: Additional props will be passed down.

Limitations

For browsers that don't support object-fit/object-position, the fallback doesn't support:

  • Event handlers like onError and onLoad.
  • Other image attributes, such as crossorigin, loading, sizes, srcset, usemap, etc…
  • CSS background images.
2.0.1

2 years ago

2.0.0

3 years ago

1.7.0

3 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago