Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the new Next.js Image component with Material UI

In Material UI the components that display images have a parameter for the image. eg:

<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />

In Next.js v10 there is a new Image component that automatically scales images: https://nextjs.org/docs/api-reference/next/image 

Has anyone figured out how to use the new Image component with Material UI?

like image 946
terchris Avatar asked Oct 15 '22 23:10

terchris


1 Answers

I am able to use it like this and it works well. I hope it will be helpful.

<Avatar className={className}>
  <Image src={src || placeholder} alt={alt} layout="fill" />
</Avatar>
like image 185
Mohd Saood akhtar Avatar answered Oct 21 '22 05:10

Mohd Saood akhtar