Image ​
An Image is a visual element used to display content in various formats and states, supporting features like aspect ratios, placeholders, and responsive sizing.
| Name | Value |
|---|---|
| Props | |
aspectRatio | |
objectFit | |
objectPosition | |
position | |
| View | |
Reading direction | |
Overview ​
When to use Image ​
Use the Image component to display visual content like photos or illustrations that enhance context and meaning of surrounding content.
Avoid using the Image component for small previews. Use the Thumbnail component instead.
Accessibility
Always provide meaningful alt text in Image to ensure accessibility.
About Image ​
Image includes the following elements.
Image ​
The Image component displays an image element if an image has been provided.
Use contextually relevant, neutral, high-quality images that accurately represent the subject and respect copyright requirements. Refer to the Style Guide to learn more about how to use images.
Placeholder icon ​
If the image is missing or loading, a placeholder icon on a background is displayed.
- Customize the icon if needed.
- Use an icon that provides clear context for the use of the Image.
Examples ​
Default ​
By default, the Image component displays an image in its original dimensions.
Aspect ratio ​
The component supports aspect ratios to preserve layout structure.
Placeholder ​
The placeholder serves two purposes:
- To display while the image is loading, improving the experience of those with slower connections.
- To display when an image is not provided.
Technical implementation ​
Vue usage ​
Props ​
| Prop name | Description | Type | Values | Default |
|---|---|---|---|---|
src | The source URL of the image. | string | - | '' |
alt(required) | Alternative text for the image. Descriptive text must be provided unless the image is decorative or described elsewhere. | string | - | '' |
aspectRatio | The aspect ratio of the image. Accepts one of the predefined aspect ratios. | ImageAspectRatio | - | null |
objectPosition | The object-position of the image when cropping with an aspect ratio. Accepts 'top', 'bottom', 'left', 'right', or 'center'. | typeof ObjectPositions[number] | - | 'center' |
objectFit | Specifies how the image should be resized to fit its container. Accepts 'fill', 'contain', 'cover', 'none', or 'scale-down'. | typeof ObjectFitOptions[number] | - | 'cover' |
position | Image position on a page | string | left, center, right | '' |
width | The width of the image in pixels. | string|number | - | undefined |
height | The height of the image in pixels. | string|number | - | undefined |
loadingPriority | The loading priority of the image. Accepts 'lazy' or 'eager'. | string | lazy, eager | 'lazy' |
Events ​
| Event name | Properties | Description |
|---|---|---|
error | event Event - The error event object. | Emitted when an error occurs loading the image. |