Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Image is not showing in the browser in Material-UI Avatar component?

I am using Material-UI Avatar React component to show profile images. While compiling it can reach the image, there is no error in compile time. But image is not showing in the browser.

Please check this image to better understand

Codes:

import {avatar} from '../../images/avatar.png';

<Box component='div'>
     <Avatar src={avatar} alt="Russel Crow"/>
</Box>

Please tell me why image is not showing in the browser and How to show it?

like image 553
geektanvir Avatar asked Sep 05 '25 04:09

geektanvir


1 Answers

You used a named import, try it like this:

import avatar from '../../images/avatar.png'
like image 123
maten Avatar answered Sep 07 '25 19:09

maten