<NuxtImg> is a drop-in replacement for the native <img> tag.
- Uses built-in provider to optimize local and remote images
- Converts
srcto provider-optimized URLs - Automatically resizes images based on
widthandheight - Generates responsive sizes when providing
sizesoption - Supports native lazy loading as well as other
<img>attributes
Setup
In order to use<NuxtImg> you should install and enable the Nuxt Image module:
Usage
<NuxtImg> outputs a native img tag directly (without any wrapper around it). Use it like you would use the <img> tag:
Props
<NuxtImg> accepts all native <img> attributes plus additional props for image optimization:
The source URL of the image.
The width of the image in pixels. Used for image optimization.
The height of the image in pixels. Used for image optimization.
Responsive sizes for different viewport widths. Example:
"sm:100vw md:50vw lg:400px"Alternative text for the image. Important for accessibility.
The target format for image optimization (e.g.,
"webp", "avif", "png").The quality of the optimized image (0-100).
Native lazy loading attribute.
The image provider to use (e.g.,
"cloudinary", "imgix", "ipx").A predefined set of image modifiers.
Learn More
NuxtImg Documentation
Read the complete documentation for
<NuxtImg> component in the Nuxt Image module docs.