Skip to content
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

[SvgIcon] color in MenuItem #4453

Closed
liesislukas opened this issue Jun 8, 2016 · 4 comments
Closed

[SvgIcon] color in MenuItem #4453

liesislukas opened this issue Jun 8, 2016 · 4 comments
Labels
component: menu This is the name of the generic UI component, not the React module! component: SvgIcon The React component. v0.x

Comments

@liesislukas
Copy link
Contributor

liesislukas commented Jun 8, 2016

Problem description

I use Svg Icon, SelectField & MenuItem.
I want to change Icon's color. It's possible with color attribute, but it's not working inside MenuItem:

I've put same icon's code near menu to show that it works w/o MenuItem

image

Steps to reproduce

import ActionLabel from 'material-ui/svg-icons/action/label';
import {red500, green500, orange500} from 'material-ui/styles/colors';
import MenuItem from 'material-ui/MenuItem';
import SelectField from 'material-ui/SelectField';

...

<ActionLabel color={orange500} />
<SelectField>
    <MenuItem
       leftIcon={<ActionLabel color={orange500} />}
       value={'medium'} key={'medium'} primaryText={'medium'}
    />
</SelectField>

...

Workaround
I'm adding icon & text as primaryText and it works, but when such item is selected layout goes out, there is extra whitespace around.

<MenuItem value={'medium'} primaryText={<span style={{display: 'flex'}}>
                    <ActionLabel color={orange500}/>
                    <span style={{lineHeight: '25px', marginLeft: 6}}>Medium</span>
                 </span>}/>

Versions

  • Material-UI: 0.15.0
  • React: 15.1.0
  • Browser: Chrome: Version 51.0.2704.84 (64-bit)
@liesislukas liesislukas changed the title [MenuItem] color [SvgIcon] color in MenuItem Jun 8, 2016
@rochdev
Copy link

rochdev commented Jun 17, 2016

Another workaround that I found for ListItem is to wrap the icon inside an avatar:

<ListItem
  leftAvatar={<Avatar icon={<ActionLabel />} backgroundColor='transparent' color={orange500} />}
/>

@nehalbhanushali
Copy link

@liesislukas Yes it does not work in Material-UI: 0.15.0. but it works perfectly fine in Material-UI:0.15.1 without any workaround.

@mpontikes
Copy link

@liesislukas Can we close this issue with @nehalbhanushali 's solution?

@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@liesislukas
Copy link
Contributor Author

@mpontikes sure, if it works - let's close

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 21, 2022
@zannager zannager added component: menu This is the name of the generic UI component, not the React module! component: SvgIcon The React component. v0.x and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module! component: SvgIcon The React component. v0.x
Projects
None yet
Development

No branches or pull requests

6 participants