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
Refactored Image component and simplified its API.
6
+
7
+
- Removed the `as`, `media`, and `sources` props, as well code paths which render a `<picture>` element. To use a `<picture>` element with the updated `Image` component, wrap the `Image` with a `picture` element, for example:
8
+
9
+
```jsx
10
+
<picture>
11
+
<source srcSet="..." media="..."/>
12
+
<Image src="..." alt="..."/>
13
+
</picture>
14
+
```
15
+
16
+
- Fixed an edge case with the border radius of the `Card.Image` component. It was previously possible for the div that wraps the image and the image itself to have different border radii.
alt="placeholder, blank area with an off-white background color"
86
-
aspectRatio="16:9"
87
-
/>
88
-
```
89
-
90
-
### Height
91
-
92
-
The `height` prop can be used to set the height of the image. This can be used along side the `aspectRatio` prop to create a responsive image the same size as other images.
81
+
The CSS `aspect-ratio` property (or `style.aspectRatio`) can be used to set the aspect ratio of the image. Note that either `width` or `height` must be set for this to take effect.
alt="placeholder, blank area with an off-white background color"
112
+
height={100}
113
+
style={{
114
+
aspectRatio:'16/9',
115
+
}}
116
+
/>
117
+
</Stack>
101
118
```
102
119
103
120
### Border radius
@@ -144,33 +161,14 @@ The `borderRadius` prop can be used to apply rounded corners to images using pre
144
161
</Stack>
145
162
```
146
163
147
-
### Width
148
-
149
-
The `width` prop can be used to set the width of the image. This can be used along side the `aspectRatio` prop to create a responsive image the same size as other images.
|`src`|`string`||`true`| Specifies the path to the image |
167
-
|`alt`|`string`||`true`| Specifies a text value explaining the nature of the image for users of assistive technology |
168
-
|`as`|`img`, `picture`|`img`|`false`| Specification to create a picture component |
169
-
|`sources`|`{srcset: string, media: string}[]`||`false`| When picture is specified in the `as` prop sources allows you to set the source elements. |
170
-
|`aspectRatio`|`'1:1'`, `'16:9'`, `'16:10'`, `'4:3'`, `'custom'`|`undefined`|`false`| Sets the image aspect ratio. A custom ratio can be provided in the design tokens. |
171
-
|`borderRadius`| <PropTableValuesvalues={[...ImageBorderRadiusOptions]}commaSeparated /> |`undefined`|`false`| Applies a system-level border radius value to the Image. |
172
-
|`height`|`number`||`false`| The height of the image element or its container if it has an aspect ratio |
173
-
|`width`|`number`||`false`| The width of the image element or its container if it has an aspect ratio |
174
-
|`loading`|`eager`, `lazy`|`eager`|`false`| The loading attribute specifies whether a browser should load an image immediately or to defer loading of off-screen images until for example the user scrolls near them. |
175
-
|`decoding`|`sync`, `async`, `auto`|`sync`|`false`| Sets the image decoding strategy. Representing a hint given to the browser on how it should decode the image. |
176
-
|`className`|`string`||`false`| Sets a custom CSS class |
168
+
All standard `img` attributes are supported as defined by `React.ImgHTMLAttributes<HTMLImageElement>` with the following additions.
169
+
170
+
| name | type | default | required | description |
|`alt`|`string`||`true`| Specifies a text value explaining the nature of the image for users of assistive technology. |
173
+
|`animate`|`AnimateProps`|`undefined`|`false`| When wrapped in an `<AnimationProvider>`, applies an animation preset. |
174
+
|`borderRadius`| <PropTableValuesvalues={[...ImageBorderRadiusOptions]}commaSeparated /> |`undefined`|`false`| Applies a system-level border radius value to the Image. |
0 commit comments