Image
The image component embeds images within the interface with control over presentation and loading behavior. Use image to visually illustrate concepts, showcase products, display user content, or support tasks and interactions with visual context.
Images support responsive sizing, alt text for accessibility, aspect ratio control, and loading states for progressive enhancement. For small preview images in lists or tables, use thumbnail. For profile images, use avatar.
Anchor to PropertiesProperties
- Anchor to idididstringstringrequiredrequired
- Anchor to originalSrcoriginalSrcoriginalSrcstringstringrequiredrequired
- Anchor to altTextaltTextaltTextstringstring
Anchor to EventsEvents
The image component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to errorerrorerrorOnErrorEventHandlerOnErrorEventHandlerrequiredrequired
A callback fired when the image fails to load.
Learn more about the error event.
- Anchor to loadloadloadCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired when the image successfully loads.
Learn more about the load event.
CallbackEventListener
A function that handles events from UI components. This type represents an event listener callback that receives a `CallbackEvent` with a strongly-typed `currentTarget`. Use this for component event handlers like `click`, `focus`, `blur`, and other DOM events.
(EventListener & {
(event: CallbackEvent<T>): void;
}) | nullCallbackEvent
An event object with a strongly-typed `currentTarget` property that references the specific HTML element that triggered the event. This type extends the standard DOM `Event` interface and ensures type safety when accessing the element that fired the event.
Event & {
currentTarget: HTMLElementTagNameMap[T];
}Anchor to ExamplesExamples
Anchor to Display a product thumbnailDisplay a product thumbnail
Display a product thumbnail with metadata in a grid layout. This example demonstrates how to control image sizing with aspectRatio, objectFit, and inlineSize, and round corners with borderRadius.
Preview
html
Anchor to Set an aspect ratioSet an aspect ratio
Control image proportions with a fixed aspect ratio. This example displays a 16:9 image that scales to fill its container using objectFit="cover", with lazy loading for performance.
Preview
html
Anchor to Use responsive imagesUse responsive images
Set up responsive image sources using srcSet and sizes. This example demonstrates how to configure the browser to select appropriate image sources based on viewport width.
Preview
html
Anchor to Add border stylingAdd border styling
Add visual emphasis with border styling. This example displays an image with border width, color, and rounded corners.
Preview
html
Anchor to Mark as decorativeMark as decorative
Hide images from screen readers when purely decorative. This example presents an image with empty alt text and presentation role for accessibility.
Preview
html
Anchor to Use in a grid layoutUse in a grid layout
Build a product image gallery with consistent sizing using grid. This example arranges three product photos in a row, each constrained to a square with rounded corners so they line up evenly.
Preview
html
Anchor to Useful forUseful for
- Adding illustrations and photos.
Anchor to Best practicesBest practices
- Use high-resolution, optimized images.
- Use intentionally to add clarity and guide users.
Anchor to Content guidelinesContent guidelines
Alt text should be accurate, concise, and descriptive:
- Indicate it's an image: "Image of", "Photo of".
- Focus on description: "Image of a woman with curly brown hair smiling".