Image
Display images with enhanced loading states, accessibility features, and flexible layout options. Image provides skeleton placeholders, fade-in animations, and caption support.
Installation
shellUsage
tsxProps
Object Fit
Use the fit prop to control how the image scales to fit its container.
Cover
Scales image to cover the entire container. May crop edges but ensures no empty space. Best for hero images, thumbnails, and card backgrounds.
tsxContain
Scales image to fit entirely within the container. May leave empty space but shows the complete image. Best for product images, logos, and artwork.
tsxFill
Stretches image to fill the container exactly. May distort aspect ratio. Use with caution.
tsxScale Down
Acts like contain but never scales up beyond the original size. Prevents small images from becoming pixelated. Best for user-uploaded content.
tsxNone
Image keeps its original size. May overflow container or leave empty space. Best for pixel-perfect images.
tsxRadius
Use the radius prop to apply rounded corners to images.
tsxLoading States
Skeleton Placeholder
Use showSkeleton to display a skeleton animation while the image loads.
tsxLQIP Placeholder
Use the placeholder prop with a low-quality image placeholder (LQIP) for a blurred preview while the main image loads.
tsxCombined
Combine skeleton and placeholder for the best loading experience.
tsxFade In
By default, images fade in when loaded. Disable this with fadeIn={false}.
tsxCaptions
Use the caption prop to add descriptive text below the image.
tsxtsxLazy Loading
Images use loading="lazy" by default for performance. Use loading="eager" for above-the-fold images.
tsxEvent Handlers
Handle load and error events for custom behavior.
tsxWith Next.js Image
Use the as prop to render with Next.js Image for automatic optimization.
tsxLayout Props
Image supports margin, width, and height props for layout control.
tsxResponsive Fit
Use responsive objects to change fit behavior across breakpoints.
tsxPractical Examples
Product Card Image
tsxAvatar
tsxHero Image
tsxChart with Caption
tsxGallery Image
tsxAccessibility
Image provides comprehensive accessibility support.
Required Alt Text
The alt prop is required. Provide meaningful descriptions for screen readers.
tsxLoading Announcements
Screen readers announce loading state via loadingAriaLabel.
tsxError Announcements
Screen readers announce errors via errorAriaLabel.
tsxARIA Attributes
Image automatically sets:
aria-busy="true"during loadingaria-invalid="true"on erroraria-describedbylinking to error message
Reduced Motion
Fade-in animations are disabled when the user prefers reduced motion.
High Contrast Mode
Images receive a visible border in Windows High Contrast mode for visibility.
Enhancements
Built-in Loading States
Native support for skeleton placeholders and LQIP patterns without additional wrapper components.
Automatic Caching Detection
Image detects already-cached images and skips the loading state for instant display.
Caption Support
Built-in caption styling with proper typography and spacing, eliminating the need for custom figure/figcaption markup.
Polymorphic Rendering
Use the as prop for seamless integration with Next.js Image or other optimized image components.
Changelog
0.1.95
Simplified component architecture and improved Next.js compatibility.
Added
- Polymorphic
asprop for Next.js Image and custom component support - Comprehensive test suite (35 tests)
Changed
- Flattened DOM structure (nested divs only when caption is present)
- Reduced component from ~430 to ~280 lines
Fixed
loadingAriaLabelnow properly renders screen reader announcements
Removed
- Unused
variantprop
Created
New component for Kookie UI (not part of Radix Themes).
- Enhanced image component with loading states and accessibility features
- Skeleton placeholder support via
showSkeletonprop - LQIP placeholder support via
placeholderprop - Fade-in animation with
fadeInprop (enabled by default) - Caption support with
captionprop - Comprehensive accessibility with
aria-busy,aria-invalid, and live announcements - Object-fit variants (
cover,contain,fill,scale-down,none) with responsive support - Lazy loading by default for performance
- Automatic cached image detection for instant display
- Windows High Contrast mode support
- Reduced motion support