Search code examples
reactjsmaterial-uiappbar

How do I display an image on left of Material-UI AppBar, but retain the "hamburger" menu?


I'd like to display an image on the left of a Material-UI AppBar, but keep the "hamburger" menu and have the image just to the right of that.

Is it possible? I can add an image to the left using

<AppBar title="My App"
        iconElementLeft = {<img src='header-logo.png' alt="Logo" />} />;

However, that replaces the "hamburger" menu, which is of no use to me.

I also tried creating an img as a child of the AppBar, but that puts the image to the right of any iconElementRight elements.


Solution

  • Just pass your tag as the title. Material-ui will take a node as title

    Something like

     <AppBar
        title={<img src="https://unsplash.it/40/40"/>}
      />
    

    Working pen

    Hope this helps!