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

Support icons in buttons OOTB? #279

Open
ejoubaud opened this issue May 11, 2018 · 2 comments
Open

Support icons in buttons OOTB? #279

ejoubaud opened this issue May 11, 2018 · 2 comments

Comments

@ejoubaud
Copy link

Dropping an icon in a mui button doesn't look great, it takes some tinkering:

// using react version
<Button color="primary"><i class="material-icons">done</i>Submit</Button>

gives you:

captura de pantalla 2018-05-11 a las 8 30 04

I was able to fix it somewhat with something like this (inspired by materalize-css' handling):

.mui-btn-icon-left {
  line-height: inherit;
  margin-right: 10px;
  margin-left: -5px;
  float: left;
}
<Button color="primary"><i class="material-icons mui-btn-icon-left">done</i>Submit</Button>

captura de pantalla 2018-05-11 a las 8 59 36

I'm not saying mui should come with its own icons library (#245 seems to reject that) but it would be great if there was an included/endorsed/generic way/helper for dropping icons from such a lib into a button so that it just works. This is the kind of common boilerplates we use a CSS lib to avoid.

@ejoubaud
Copy link
Author

PS: In case this doesn't make it into the core, those looking for a more Reacty solution can achieve it this way with, e.g., styled-components:

import React from 'react';
import styled from 'styled-components';

const Icon = ({ icon, className }) => (
  <i className={`material-icons ${className}`}>{icon}</i>
);

const LeftIcon = styled(Icon)`
  line-height: inherit;
  font-size: 1.3rem;
  margin-right: 15px;
  margin-left: -5px;
  float: left;
`;

<Button color="primary"><LeftIcon icon="done" />Submit</Button>

@amorey
Copy link
Member

amorey commented May 12, 2018

Thanks for creating this issue. Let me do some research on it before responding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants