Skip to content

Commit 4e8dbce

Browse files
committed
feat: add usePlaceholder to allow users to not use the blurred placeholder
1 parent 795dcd1 commit 4e8dbce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Image/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type ImagePropTypes = {
6161
explicitWidth?: boolean;
6262
/** Triggered when the image finishes loading */
6363
onLoad?(): void;
64+
/** Whether the image should use a blurred image placeholder */
65+
usePlaceholder?: boolean;
6466
};
6567

6668
type State = {
@@ -116,6 +118,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
116118
explicitWidth,
117119
data,
118120
onLoad,
121+
usePlaceholder = true,
119122
},
120123
ref
121124
) => {
@@ -170,7 +173,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
170173
const transition =
171174
fadeInDuration > 0 ? `opacity ${fadeInDuration}ms` : undefined;
172175

173-
const placeholder = (
176+
const placeholder = usePlaceholder ? (
174177
<div
175178
style={{
176179
backgroundImage: data.base64 ? `url(${data.base64})` : undefined,
@@ -181,7 +184,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
181184
...absolutePositioning,
182185
}}
183186
/>
184-
);
187+
) : null;
185188

186189
const { width, aspectRatio } = data;
187190
const height = data.height || width / aspectRatio;

0 commit comments

Comments
 (0)