Skip to content

Image

WARNING

This component is still under development. It is not yet available in releases of Codex.

An Image is a visual element used to display content in various formats and states, supporting features like aspect ratios, placeholders, and responsive sizing.

Guidelines

When to use images

Use the Image component to display visual content like photos or illustrations that enhance context and meaning. Ideal for adding visual elements in layouts, supporting text content, or embedding in components like cards and dialogs. Avoid using for purely decorative purposes or stylized visual elements. Always include meaningful alt text for accessibility.

Demos

Configurable

Olive-bellied Sunbird flying from a flower to another at Kibale forest National Park.
NameValue
Props
src
alt
aspectRatio
objectFit
objectPosition
position
width
height
View
Reading direction

Default

Olive-bellied Sunbird flying from a flower to another at Kibale forest National Park
NameValue
View
Reading direction

Aspect Ratio

An example image with aspect ratio 16:9
NameValue
View
Reading direction

Placeholder

NameValue
View
Reading direction

Error

This is an example of an image error state
NameValue
View
Reading direction

Vue usage

Props

Prop nameDescriptionTypeValuesDefault
srcThe 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-''
aspectRatioThe aspect ratio of the image.

Accepts one of the predefined aspect ratios.
ImageAspectRatio-null
objectPositionThe object-position of the image when cropping with an aspect ratio.

Accepts 'top', 'bottom', 'left', 'right', or 'center'.
typeof ObjectPositions[number]-'center'
objectFitSpecifies how the image should be resized to fit its container. Accepts 'fill', 'contain', 'cover', 'none', or 'scale-down'.typeof ObjectFitOptions[number]-'cover'
positionImage position on a pagestringleft, center, right''
widthThe width of the image in pixels.string|number-undefined
heightThe height of the image in pixels.string|number-undefined
loadingPriorityThe loading priority of the image.

Accepts 'lazy' or 'eager'.
stringlazy, eager'lazy'

Events

Event namePropertiesDescription
errorevent Event - The error event object.Emitted when an error occurs loading the image.