Add Image component
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Summary 💡
Implement an enhanced version of the native <img>
element.
Examples 🌈
import { Image } from '@material-ui/core';
<Image src="" />
Motivation 🔦
A couple of features we could bring:
- Use
display: inline-block;
to avoid layout jumps when the image is loading or broken. - Provide a custom fallback component when the image fails to load.
- Support a loading indicator when the image takes too much time to load, e.g Skeleton.
- Add a smooth animation for displaying the image once loaded.
- Support a placeholder to display while image’s loading. An image of lower resolution.
- Lazy loading? Maybe not relevant considering https://caniuse.com/#feat=loading-lazy-attr and https://web.dev/native-lazy-loading/.
- Support aspect ratio. For instance, it allows rendering an image with a width constraint without having to wait for the image to load over the networks to resolve its height (which might lead to a layout shift).
Benchmark
- https://github.com/imgix/react-imgix
- https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-image/src/index.js
- https://amp.dev/documentation/examples/components/amp-img/?format=websites
- https://vuetifyjs.com/en/components/images/#images
- https://bootstrap-vue.js.org/docs/components/image
- https://github.com/chakra-ui/chakra-ui/blob/master/packages/chakra-ui/src/Image/index.js
- https://github.com/jossmac/react-images
- https://backpack.github.io/components/image?platform=web
- https://ionicframework.com/docs/api/img
- https://github.com/FormidableLabs/react-progressive-image
- https://joshwcomeau.com/performance/embracing-modern-image-formats/
- https://github.com/konvajs/use-image/
- https://github.com/mbrevda/react-image
- https://github.com/gokcan/react-shimmer
- https://react-spectrum.adobe.com/react-spectrum/Image.html
- https://github.com/fpapado/react-lazy-images
- https://github.com/react-component/image
Issue Analytics
- State:
- Created 3 years ago
- Reactions:34
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Image - React Native
A React component for displaying different types of images, including network images, static resources, temporary local images, and images ...
Read more >Add Image component to new gameobject - Stack Overflow
1.Create a Canvas. The includes creating the GameObject that will hold the Canvas then attach Canvas component to it. · 2.Create your Image...
Read more >next/image - Next.js
The <Image /> component accepts a number of additional properties beyond those which are required. This section describes the most commonly-used properties of ......
Read more >Adding Images, Fonts, and Files - Create React App
Adding Images, Fonts, and Files. With webpack, using static assets like images and fonts works similarly to CSS.
Read more >Image Component | Adobe Experience Manager
The Image Component features adaptive image selection and responsive behavior with lazy loading for the page visitor as well as easy image ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think we can implement meaningful features since the most important ones rely on the build setup. A meta framework is far better suited to host such a component. There’s a RFC in nextjs which has far better research and highlights why this component should leverage the build setup: https://github.com/vercel/next.js/discussions/16832
@xiaoyu-tamu It reminds me of one of the reasons why we didn’t call
Typography
:Text
. In hindsight, it didn’t seem to have stopped a lot of component libraries from using this wording:As long as you have eslint or TypeScript, it should be fine:
Otherwise, it’s a nightmare:
The other reason we have kept Typography was to match the theme.typography structure. But we could also argue that using two different names would reduce confusion 🤔.