Image
Use it like an `<img>`, with extra handling built in. `alt` defaults to empty, so set it whenever the image carries meaning.
compliant
- Overview
- Props
Use it exactly like an <img /> but it has under-the-hood logic. For now, we defaulted the alt to be an empty string.
<Image src="https://picsum.photos/id/237/600/300" />
Accessibility
- The image accessibility has a fundamental rule, always specify an
altattribute, however the URL will be read by assistant technology. - But decorative image should have an empty
altattribute, however the content will be polluted by unnecessary information, like "something logo", "someone is looking at a chart on a whiteboard"... More about decorative images in the dedicated section: Decorative images.
We almost always use decorative images, then to simplify the task, alt is defaulted to an empty string.
The image doesn't bring any context
Generally, if the image doesn't contain textual information, you shouldn't specify the alt.
Adding an alt will bring noise for assistive technology like screen readers.
Let's consider we have this image:
Don't
<Image src="https://picsum.photos/id/237/600/300" alt="A nice picture of a dog" />
Do
Because it doesn't bring any additional information.
<Image src="https://picsum.photos/id/237/600/300" />
The image brings context
If your image contains textual information, or in really specific cases the content of the image brings context. Then you can specify the alt.
Let's consider we have this image:
Don't
Not specifying an alt will cause a loss of information.
<Image src="/static/img/component-image-example1.png" />
Do
Provide a brief alt description summarizing the image content in a concise sentence.
<Image
src="/static/img/component-image-example1.png"
alt="Zoo repartition is composed by 5 tigers and 10 elephants"
/>
Image with a lot of information
In that kind of case, you should structure the information outside of the alt, with regular HTML elements.
Let's consider we have this image:
Transcribing the entire content of this image in the alt attribute is not feasible. In such cases, do not set the alt attribute and instead describe the image content above it.
These cases are rare and do not have a universal solution. If you come across such a scenario, feel free to reach out to @accessibility_help on Slack.
Playground
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| alt | any | |||
| aria-hidden | any | |||
| className | any | |||
| css | any | |||
| height | any | |||
| loading | any | |||
| role | any | |||
| src | any | |||
| style | any | |||
| width | any |