-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Menu] Support grouping / categories #2671
Comments
Thanks 👍 👍 |
@oliviertassinari Can I try this one?.. If yes, Can I create seperate component or alter the existing select component to achieve this??. |
@Ajay2507 We have to address more important and core issues with the Select before thinking of adding new features:
|
Okay. Will look into those issues. |
hey, any updates on this feature request? |
Do we have any progress on this? are the more important issues that oliviertassinari listed still being worked on? |
I am very interested in this as well! It would be fantastic to have this be a possibility without using a native select styling. |
+1 on the waiting list for this one... |
I've made a component that implements this, I can post a repo with this on the weekend. |
As a walkaround, you can use the following snippet to get appearance pretty closely matching what the native one would be. One disadvantage to this approach is definitely accessibility though. Anyway, this works for me and might be useful to somebody else, so I'm posting it.
|
I get unexpected strange behaviour when doing that where I cannot debug or modify the style of the disabled groups properly, sometimes they will show gray, and they cannot be debugged on why they show as gray. |
Added some CSS rules and now it seems to be perfect:
|
For the interested, I create a DRY way to the @jankalfus amazing solution: import React from 'react';
import MenuItem from "@material-ui/core/MenuItem";
import withStyles from "@material-ui/core/styles/withStyles";
const styles = theme => ({
item: {
paddingLeft: theme.spacing(3),
},
group: {
fontWeight: theme.typography.fontWeightMedium,
opacity: 1,
},
});
const customMenuItem = ({ classes, children, groupHead, groupItem, ...props}) => {
let disabled = false;
let className = [props.className];
if (groupHead) {
disabled = true;
className.push(classes.group);
}
if (groupItem) {
className.push(classes.item);
}
return <MenuItem
disabled={disabled}
className={className.join(' ')}
{...props}>{children}</MenuItem>;
};
const AppMenuItem = withStyles(styles)(customMenuItem);
export default AppMenuItem; And can use this way:
|
Actually, I'd recommend just creating two styled components:
and use them like this:
It's more simple, without any logic. I haven't tested the code above, but you get the idea :) |
Please add feature like this
The text was updated successfully, but these errors were encountered: