How to add `alt` to <Image> component
Giggiux opened this issue · 5 comments
Giggiux commented
for SEO optimization the image's alt
tag is needed.
It would be optimal to have it on the Image component.
gokcan commented
You may use the NativeImgProps
prop to pass alt
to the underlying <img>
.
arifals27 commented
You may use the
NativeImgProps
prop to passalt
to the underlying<img>
.
can you give example how to use NativeImgProps
Giggiux commented
@arifals27 I haven't used this in 2 years now, but I guess you may just do something like <Image NativeImgProps={{alt:"my alt text"}}>
here is the line that adds that NativeImgProps to the Image props
gokcan commented
Example usage:
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} />}
NativeImgProps={{ alt: "Descriptive text." }}
/>
</div>
)
}
rajnikantwebdev commented