API and Development
Image supports four modes via a discriminated union: pass src for URL/raster images (native <img>), svg for trusted inline SVG components from a local ?react import, or lightSrc/darkSrc / lightSvg/darkSvg for theme-aware variants. Shared layout props (fill, width, height, objectFit, objectPosition) apply in all modes. URL mode additionally supports lazy loading, priority preloading, blur placeholders, load/error callbacks, responsive srcSet/sizes, and alternate-format sources (rendered as a native <picture>).
Themed modes render both sources and toggle visibility with CSS keyed on ancestor .light / .light-theme / .radix-themes.light or .dark / .dark-theme / .radix-themes.dark classes. In themed modes, id is applied to a display: contents themed root, and onLoad / onError are forwarded to both URL variants.
Modeled on the Next.js Image layout/perf API. Server-only optimization props (loader, quality, unoptimized) are not supported in ui-core.
Name | Type | Default | Description |
|---|---|---|---|
|
| — | Accessible description of the image. Required for non-decorative images. |
|
| — | Low-resolution image URL displayed while the main image loads when |
|
| — | Additional CSS class name(s) applied to the underlying element. |
|
| — | Themed URL sources are not used in single URL mode. Themed URL sources are not used in single inline SVG mode. Image URL shown when the active theme is dark. Themed URL sources are not used in themed inline SVG mode. |
|
| — | Themed inline SVG sources are not used in single URL mode. Themed inline SVG sources are not used in single inline SVG mode. Themed inline SVG sources are not used in themed URL mode. Inline SVG component shown when the active theme is dark. |
|
| — | When true, the image fills its nearest positioned ancestor (omit |
|
| — | Intrinsic height in pixels; helps reserve layout space and avoid CLS. |
|
| — | Stable DOM id forwarded to the underlying element. |
|
| — | Themed URL sources are not used in single URL mode. Themed URL sources are not used in single inline SVG mode. Image URL shown when the active theme is light. Themed URL sources are not used in themed inline SVG mode. |
|
| — | Themed inline SVG sources are not used in single URL mode. Themed inline SVG sources are not used in single inline SVG mode. Themed inline SVG sources are not used in themed URL mode. Inline SVG component shown when the active theme is light. |
|
| — | Native lazy/eager loading; defaults to |
|
| — | Maps to CSS |
|
| — | Maps to CSS |
|
| — | Fired when the image fails to load. Fired when either theme variant fails to load. |
|
| — | Fired when the image finishes loading. Fired when either theme variant finishes loading. |
|
|
| Placeholder behavior while the image loads. |
|
| — | When true, preloads the image with high fetch priority (eager loading). |
|
| — | React ref forwarded to the underlying |
|
| — | Responsive image sizes hint forwarded to the native |
|
| — | Alternate-format candidates offered ahead of |
|
| — | Image URL (static import, public path, or remote URL). Image URL source is not used in inline SVG mode. Single image URL is not used in themed URL mode. Single image URL is not used in themed inline SVG mode. |
|
| — | Responsive candidate set forwarded to the native |
|
| — | Trusted inline SVG component from a local |
|
| — | Intrinsic width in pixels; helps reserve layout space and avoid CLS. |
Interactive examples and edge cases for this component are in Storybook.
Offer newer formats ahead of a universally supported src fallback. The browser takes the first type it can decode. List newest-first (AVIF → WebP).