To add the Image
component to your app:
1 2import { Image } from '@forge/react';
An image component to display images.
Name | Type | Required | Description |
---|---|---|---|
alt | string | Yes | The alternative text displayed if the image is not loaded. |
src | string | Yes | The remote URL of the image or a reference to a local import (see local image). |
size | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | No | The size of the image. Defaults to xlarge . |
If you are using a URL for the image src
, make sure that the image URL is added to the app's manifest file to load the image.
For more information on how to declare image sources in an application's manifest file, see image permissions documentation.
Example to add an image URL in the manifest
1 2permissions: external: images: - '<ImageURL>'
The image size
property is relative to the container.
Here's an example with different image
size
props, to help illustrate how to use the image component in an app.
1 2import React from 'react'; import { Image } from '@forge/react'; // Importing the 'myCat' image from the project's folder for use in the component. import { myCat } from './myCat.png' export const App = () => ( <Image src={myCat} alt="black and white cat lying on brown bamboo chair inside room" /> );
1 2import React from 'react'; import { Image } from '@forge/react'; export const App = () => ( <Image src="<ImageURL>" alt="black and white cat lying on brown bamboo chair inside room" /> );
1 2import React from 'react'; import { Image } from '@forge/react'; export const App = () => ( <Image src="https://media.giphy.com/media/jUwpNzg9IcyrK/source.gif" alt="Example of an animated GIF depicting Homer Simpson retreating into bushes, referencing the popular 'Homer Simpson disappearing' meme" /> );
Text Alternatives (alt text) are an important factor in digital accessibility as they provide an easy way for non-text content (as per WCAG success criterion) to be perceived through various methods including Assistive Technology. Alt text is informative content which conveys the meaning of non-decorative images, and also provides content when images are slow or fail to load.
This helps users who use:
In order to first apply alt text correctly, we need to determine whether an image conveys any meaning (non-decorative) or whether it is purely for presentation purposes (decorative).
Non-decorative images
Require image descriptions as they convey meaning or add context to the content. In order to write the most appropriate alt text (image description) for an image, keep the following in mind:
Decorative images
Do not require image descriptions because they are purely presentational and part of the overall design.
alt=""
.Rate this page: