Image Optimization can be enabled via the `Image` component exported by `next/image`.
Image Optimization can be enabled via the `<Image />` component exported by
`next/image`.
## Usage
## Usage
...
@@ -57,41 +59,49 @@ export default Home
...
@@ -57,41 +59,49 @@ export default Home
## Required Props
## Required Props
The `Image` component requires the following properties.
The `<Image />` component requires the following properties.
### src
### src
The path or URL to the source image. This is required.
The path or URL to the source image. This is required.
When using an external URL, you must add it to [domains](/docs/basic-features/image-optimization.md#domains) in `next.config.js`.
When using an external URL, you must add it to
[domains](/docs/basic-features/image-optimization.md#domains) in
`next.config.js`.
### width
### width
The width of the image, in pixels. Must be an integer without a unit.
The width of the image, in pixels. Must be an integer without a unit.
Required unless [layout="fill"`](#layout).
Required unless [`layout="fill"`](#layout).
### height
### height
The height of the image, in pixels. Must be an integer without a unit.
The height of the image, in pixels. Must be an integer without a unit.
Required unless [layout="fill"`](#layout).
Required unless [`layout="fill"`](#layout).
## Optional Props
## Optional Props
The `Image` component optionally accepts the following properties.
The `<Image />` component optionally accepts the following properties.
### layout
### layout
The layout behavior of the image as the viewport changes size. Defaults to `intrinsic`.
The layout behavior of the image as the viewport changes size. Defaults to
`intrinsic`.
When `fixed`, the image dimensions will not change as the viewport changes (no responsiveness) similar to the native `img` element.
When `fixed`, the image dimensions will not change as the viewport changes (no
responsiveness) similar to the native `img` element.
When `intrinsic`, the image will scale the dimensions down for smaller viewports but maintain the original dimensions for larger viewports.
When `intrinsic`, the image will scale the dimensions down for smaller viewports
but maintain the original dimensions for larger viewports.
When `responsive`, the image will scale the dimensions down for smaller viewports and scale up for larger viewports.
When `responsive`, the image will scale the dimensions down for smaller
viewports and scale up for larger viewports.
When `fill`, the image will stretch both width and height to the dimensions of the parent element, usually paired with [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit).
When `fill`, the image will stretch both width and height to the dimensions of