question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[List] ListItemIcon color is too strict

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

image

When hovering on a list item containing: ListItemText, ExpandLess and ListItemIcon, we see that the ListItemText and ExpandLess icon receive a hover color. This is fairly simple:

image

This doesn’t include the ListItemIcon however

Expected Behavior 🤔

We want this image

Steps to Reproduce 🕹

The code for the expected behavior is a bit strange:

https://codesandbox.io/s/material-demo-forked-l8nyn?file=/demo.js

image

image

->

image

Your Environment 🌎


System:
    OS: Windows 10 10.0.17763
  Binaries:
    Node: 12.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 90.0.4430.93
    Edge: Not Found
  npmPackages:
    @material-ui/core: ^4.11.3 => 4.11.3
    @material-ui/icons: ^4.11.2 => 4.11.2
    @material-ui/styles:  4.11.3
    @material-ui/system:  4.11.3
    @material-ui/types:  5.1.0
    @material-ui/utils:  4.11.2
    @types/react:  17.0.3
    react: ^17.0.2 => 17.0.2
    react-dom: 

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Jul 13, 2021

I had explored the color part of this issue in #24941. I have tried something but it didn’t work back then. Maybe we could continue from this proposal: https://github.com/mui-org/material-ui/issues/24941#issuecomment-785986913?

diff --git a/packages/material-ui/src/ListItemIcon/ListItemIcon.js b/packages/material-ui/src/ListItemIcon/ListItemIcon.js
index d6c4b03836..aa4c578eee 100644
--- a/packages/material-ui/src/ListItemIcon/ListItemIcon.js
+++ b/packages/material-ui/src/ListItemIcon/ListItemIcon.js
@@ -25,10 +25,11 @@ const ListItemIconRoot = styled('div', {

     return [styles.root, styleProps.alignItems === 'flex-start' && styles.alignItemsFlexStart];
   },
-})(({ theme, styleProps }) => ({
+})(({ styleProps }) => ({
   /* Styles applied to the root element. */
   minWidth: 56,
-  color: theme.palette.action.active,
+  opacity: 0.65,
+  color: 'inherit',
   flexShrink: 0,
   display: 'inline-flex',
   /* Styles applied to the root element when the parent `ListItem` uses `alignItems="flex-start"`. */

output:

Capture d’écran 2021-07-14 à 00 42 59

with a style={{ color: 'red' }} on the second <ListItem>.

1reaction
siriwatknpcommented, Jul 14, 2021

I think ListItemIcon works as expected because of the styling below so the color is needed to be overridden.

// ListItemIcon.js
  root: {
    minWidth: 56,
    color: theme.palette.action.active,
    flexShrink: 0,
    display: 'inline-flex',
  },
Read more comments on GitHub >

github_iconTop Results From Across the Web

[List] ListItemIcon color is too strict #26267 - mui/material-ui
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
Change Color in react material UI ListItemIcon - Stack Overflow
I am trying listitem icon red but not getting ...
Read more >
React MUI ListItemIcon API - GeeksforGeeks
Syntax: Create ListItemIcon in List as follows. ... 2: In the following example, we have different colors for different ListItemIcons.
Read more >
ListItemIcon API - Material UI - MUI
A simple wrapper to apply List styles to an Icon or SvgIcon . Component name. The name MuiListItemIcon can be used when providing...
Read more >
Icon List Widget - Elementor
Learn everything about Icon List Widget in this article from Elementor's ... of the divider relative to the container; Color: Choose the divider's...
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