[MenuItem] Links within Menu items

See original GitHub issue

Hi, I was looking at the current implementation of menu items and noticed that there is no actual link (meaning, html <a> tag). As a result, for instance, even in the navigation bar there is no actual link, and transitions to other pages are managed via onclick events.

I think having links would be an improvement, especially considering server-side rendered pages.

Do you think this make sense, or do you have specific reasons to not go in this direction?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:2
  • Comments:43 (8 by maintainers)

github_iconTop GitHub Comments

63reactions
DaxChencommented, Dec 9, 2017

Use the containerElement prop!

see: http://stackoverflow.com/questions/32106513/material-ui-menu-using-routes/34507786#34507786

<MenuItem
  containerElement={<Link to="/profile" />}
  primaryText="Profile"
  leftIcon={
    <FontIcon className="material-icons">people</FontIcon>
  } />
30reactions
mririgoyencommented, Nov 8, 2018

I’m coming to add to this, in case someone else stumbled upon it as well.

On v3.4, you can achieve this like so:

import { Link } from 'react-router-dom';
import MenuItem from '@material-ui/core/MenuItem';

...

<MenuItem component={Link} to="/your-path">...</MenuItem>
Read more comments on GitHub >

github_iconTop Results From Across the Web

[MenuItem] Links within Menu items · Issue #204 - GitHub
Hi, I was looking at the current implementation of menu items and noticed that there is no actual link (meaning, html <a> tag)....
Read more >
Material UI Menu using routes - reactjs - Stack Overflow
As you can see, the MenuItem component is surrounded by the Link component, and I added a style textDecoration: 'none' not to have...
Read more >
The Complete MUI MenuItem Guide (Links, Disabled, Select ...
The first MenuItem is a link, the next two are in a selected state, and the final ... MUI MenuItems with links, disabled...
Read more >
Menu Items & Menu Item Links : Support Center
Menu Item Links allow the User to link together more than one POS item to one R365 Menu Item. This is especially helpful...
Read more >
Add a menu item that links to a page section | Beaver Builder ...
You can add a menu item whose link goes to a specific section on the same page or a section on a different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found