You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR updates the docs for the following code change:
- #41399
There are a few updates here:
- [x] Update docs
- [x] Update links to docs inside component
- [x] Update examples
- [x] Fix corner cases in codemod
Copy file name to clipboardexpand all lines: docs/basic-features/image-optimization.md
+11-23
Original file line number
Diff line number
Diff line change
@@ -28,12 +28,6 @@ To add an image to your application, import the [`next/image`](/docs/api-referen
28
28
importImagefrom'next/image'
29
29
```
30
30
31
-
Alternatively, you can import [`next/future/image`](/docs/api-reference/next/future/image.md) if you need a component much closer to the native `<img>` element:
32
-
33
-
```jsx
34
-
importImagefrom'next/future/image'
35
-
```
36
-
37
31
Now, you can define the `src` for your image (either local or remote).
38
32
39
33
### Local Images
@@ -151,15 +145,15 @@ Because `next/image` is designed to guarantee good performance results, it canno
151
145
152
146
1. Automatically, using a [static import](#local-images)
153
147
2. Explicitly, by including a [`width`](/docs/api-reference/next/image.md#width) and [`height`](/docs/api-reference/next/image.md#height) property
154
-
3. Implicitly, by using [`layout="fill"`](/docs/api-reference/next/image.md#layout) which causes the image to expand to fill its parent element.
148
+
3. Implicitly, by using [fill](/docs/api-reference/next/image.md#fill) which causes the image to expand to fill its parent element.
155
149
156
150
> ### What if I don't know the size of my images?
157
151
>
158
152
> If you are accessing images from a source without knowledge of the images' sizes, there are several things you can do:
159
153
>
160
-
> **Use `layout='fill'`**
154
+
> **Use `fill``**
161
155
>
162
-
> The `fill` layout mode allows your image to be sized by its parent element. Consider using CSS to give the image's parent element space on the page, then using the [`objectFit property`](/docs/api-reference/next/image.md#objectfit)with `fill`, `contain`, or `cover`, along with the [`objectPosition property`](/docs/api-reference/next/image.md#objectposition) to define how the image should occupy that space.
156
+
> The [`fill`](/docs/api-reference/next/image#fill) prop allows your image to be sized by its parent element. Consider using CSS to give the image's parent element space on the page along [`sizes`](/docs/api-reference/next/image#sizes) prop to match any media query break points. You can also use [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit)with `fill`, `contain`, or `cover`, and [`object-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) to define how the image should occupy that space.
163
157
>
164
158
> **Normalize your images**
165
159
>
@@ -175,27 +169,21 @@ If none of the suggested methods works for sizing your images, the `next/image`
175
169
176
170
> Note: Many of the styling issues listed below can be solved with [`next/future/image`](/docs/api-reference/next/future/image.md)
177
171
178
-
Styling the Image component is not that different from styling a normal `<img>` element, but there are a few guidelines to keep in mind:
179
-
180
-
**Pick the correct layout mode**
181
-
182
-
The image component has several different [layout modes](/docs/api-reference/next/image.md#layout) that define how it is sized on the page. If the styling of your image isn't turning out the way you want, consider experimenting with other layout modes.
183
-
184
-
**Target the image with className, not based on DOM structure**
172
+
Styling the Image component is similar to styling a normal `<img>` element, but there are a few guidelines to keep in mind:
185
173
186
-
For most layout modes, the Image component will have a DOM structure of one `<img>` tag wrapped by exactly one `<span>`. For some modes, it may also have a sibling `<span>` for spacing. These additional `<span>` elements are critical to allow the component to prevent layout shifts.
174
+
**Use `className` or `style`, not `styled-jsx`**
187
175
188
-
The recommended way to style the inner `<img>` is to set the `className` prop on the Image component to the value of an imported [CSS Module](/docs/basic-features/built-in-css-support.md#adding-component-level-css). The value of `className` will be automatically applied to the underlying `<img>` element.
176
+
In most cases, we recommend using the `className` prop. This can be an imported [CSS Module](/docs/basic-features/built-in-css-support.md#adding-component-level-css), a [global stylesheet](/docs/basic-features/built-in-css-support#adding-a-global-stylesheet), etc.
189
177
190
-
Alternatively, you can import a [global stylesheet](/docs/basic-features/built-in-css-support#adding-a-global-stylesheet) and manually set the `className` prop to the same name used in the global stylesheet.
178
+
You can also use the `style` prop to assign inline styles.
191
179
192
-
You cannot use [styled-jsx](/docs/basic-features/built-in-css-support.md#css-in-js) because it's scoped to the current component.
180
+
You cannot use [styled-jsx](/docs/basic-features/built-in-css-support.md#css-in-js) because it's scoped to the current component (unless you mark the style as `global`).
193
181
194
-
**When using `layout='fill'`, the parent element must have `position: relative`**
182
+
**When using `fill`, the parent element must have `position: relative`**
195
183
196
184
This is necessary for the proper rendering of the image element in that layout mode.
197
185
198
-
**When using `layout='responsive'`, the parent element must have `display: block`**
186
+
**When using `fill`, the parent element must have `display: block`**
199
187
200
188
This is the default for `<div>` elements but should be specified otherwise.
201
189
@@ -205,7 +193,7 @@ This is the default for `<div>` elements but should be specified otherwise.
205
193
206
194
### Styling Examples
207
195
208
-
For examples of the Image component used with the various fill modes, see the [Image component example app](https://image-component.nextjs.gallery/).
196
+
For examples of the Image component used with the various styles, see the [Image component example app](https://image-component.nextjs.gallery).
0 commit comments