Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add border radius to next js image?

Tags:

next.js

i have problem with Next.js image component when i add objectFit="cover" to Image my border radius disappears. can anyone help?

like image 982
Sarang Sami Avatar asked Sep 13 '25 08:09

Sarang Sami


2 Answers

Use overflow: hidden on the div wrapping the image:

<div style={{borderRadius: '5px', overflow: 'hidden'}}>
  <Image src="..." layout="fill" objectFit="cover" />
</div>
like image 170
Alex A. Avatar answered Sep 16 '25 16:09

Alex A.


you can add a class to your image and change css in global css. beware you can not change your class attribute in jsx css or inline style

like image 21
arman amirkamali Avatar answered Sep 16 '25 18:09

arman amirkamali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!