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

EMAIL buttons are not colored #284

Open
mathiasleroy opened this issue May 28, 2018 · 3 comments
Open

EMAIL buttons are not colored #284

mathiasleroy opened this issue May 28, 2018 · 3 comments

Comments

@mathiasleroy
Copy link

mathiasleroy commented May 28, 2018

Buttons do not render correctly in emails (outlook & gmail) : I don't see any color e.g.
it works well when stored to html file and viewed in browser
but not when send via email.

(I hope I'm doing it right, let me know otherwise)

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  <html xmlns='http://www.w3.org/1999/xhtml'>
    <head>
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
      <meta name='viewport' content='width=device-width' />
      <!-- NOTE: external links are for testing only -->
      <!-- <link href='https://cdn.muicss.com/mui-0.9.39/email/mui-email-styletag.css' rel='stylesheet' /> -->
      <!-- <link href='https://cdn.muicss.com/mui-0.9.39/email/mui-email-inline.css' rel='stylesheet' /> -->
      <style>

        #outlook a{padding:0}
        .ExternalClass,.ReadMsgBody{width:100%}
        .ExternalClass,.ExternalClass div,.ExternalClass font,.ExternalClass p,.ExternalClass span,.ExternalClass td{line-height:100%}
        .mui-container-fixed{width:600px;display:block;margin:0 auto;clear:both;text-align:left;padding-left:15px;padding-right:15px}

        body{width:100%!important;min-width:100%;margin:0;padding:0}
        img{border:0 none;height:auto;line-height:100%;outline:0;text-decoration:none}
        a img{border:0 none}
        table{border-spacing:0;border-collapse:collapse}
        td{padding:0;text-align:left;word-break:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse!important}
        table,td{mso-table-lspace:0;mso-table-rspace:0}
        body,table,td,p,a,li,blockquote{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
        img{-ms-interpolation-mode:bicubic}
        body{color:#212121;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,'Trebuchet MS';font-weight:400;font-size:14px;line-height:1.429;letter-spacing:.001em;background-color:#FFF}
        a{color:#2196f3;text-decoration:none}
        p{margin:0 0 10px}
        hr{color:#e0e0e0;background-color:#e0e0e0;height:1px;border:0}
        strong{font-weight:700}
        h1,h2,h3{margin-top:20px;margin-bottom:10px}
        h4,h5,h6{margin-top:10px;margin-bottom:10px}
        .mui-body{margin:0;padding:0;height:100%;width:100%;color:#212121;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,'Trebuchet MS';font-weight:400;font-size:14px;line-height:1.429;letter-spacing:.001em;background-color:#FFF}
        .mui-btn{cursor:pointer;white-space:nowrap}
        a.mui-btn{font-weight:500;font-size:14px;color:#212121;line-height:14px;letter-spacing:.03em;text-transform:uppercase;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent;border-top:1px solid #FFF;border-left:1px solid #FFF;border-right:1px solid #FFF;border-bottom:1px solid #FFF;color:#212121;background-color:#FFF;display:inline-block;text-decoration:none;text-align:center;border-radius:3px;padding:10px 25px;background-color:transparent}
        a.mui-btn.mui-btn--raised{border-top:1px solid #f2f2f2;border-left:1px solid #e6e6e6;border-right:1px solid #e6e6e6;border-bottom:2px solid #bababa}
        a.mui-btn.mui-btn--flat{background-color:transparent;color:#212121;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        a.mui-btn.mui-btn--primary{border-top:1px solid #2196f3;border-left:1px solid #2196f3;border-right:1px solid #2196f3;border-bottom:1px solid #2196f3;color:#FFF;background-color:#2196f3}
        a.mui-btn.mui-btn--primary.mui-btn--raised{border-top:1px solid #51adf6;border-left:1px solid #2196f3;border-right:1px solid #2196f3;border-bottom:2px solid #0a6ebd}
        a.mui-btn.mui-btn--primary.mui-btn--flat{background-color:transparent;color:#2196f3;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        a.mui-btn.mui-btn--danger{border-top:1px solid #f44336;border-left:1px solid #f44336;border-right:1px solid #f44336;border-bottom:1px solid #f44336;color:#FFF;background-color:#f44336}
        a.mui-btn.mui-btn--danger.mui-btn--raised{border-top:1px solid #f77066;border-left:1px solid #f44336;border-right:1px solid #f44336;border-bottom:2px solid #d2190b}
        a.mui-btn.mui-btn--danger.mui-btn--flat{background-color:transparent;color:#f44336;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        a.mui-btn.mui-btn--dark{border-top:1px solid #424242;border-left:1px solid #424242;border-right:1px solid #424242;border-bottom:1px solid #424242;color:#FFF;background-color:#424242}
        a.mui-btn.mui-btn--dark.mui-btn--raised{border-top:1px solid #5c5c5c;border-left:1px solid #424242;border-right:1px solid #424242;border-bottom:2px solid #1c1c1c}
        a.mui-btn.mui-btn--dark.mui-btn--flat{background-color:transparent;color:#424242;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        a.mui-btn.mui-btn--accent{border-top:1px solid #ff4081;border-left:1px solid #ff4081;border-right:1px solid #ff4081;border-bottom:1px solid #ff4081;color:#FFF;background-color:#ff4081}
        a.mui-btn.mui-btn--accent.mui-btn--raised{border-top:1px solid #ff73a3;border-left:1px solid #ff4081;border-right:1px solid #ff4081;border-bottom:2px solid #f30053}
        a.mui-btn.mui-btn--accent.mui-btn--flat{background-color:transparent;color:#ff4081;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        table.mui-btn>tr>td,table.mui-btn>tbody>tr>td{background-color:#FFF}
        table.mui-btn>tr>td>a,table.mui-btn>tbody>tr>td>a{color:#212121;border-top:1px solid #FFF;border-left:1px solid #FFF;border-right:1px solid #FFF;border-bottom:1px solid #FFF}
        table.mui-btn.mui-btn--raised>tr>td>a,table.mui-btn.mui-btn--raised>tbody>tr>td>a{border-top:1px solid #f2f2f2;border-left:1px solid #e6e6e6;border-right:1px solid #e6e6e6;border-bottom:2px solid #bababa}
        table.mui-btn.mui-btn--flat>tr>td,table.mui-btn.mui-btn--flat>tbody>tr>td{background-color:transparent}
        table.mui-btn.mui-btn--flat>tr>td>a,table.mui-btn.mui-btn--flat>tbody>tr>td>a{color:#212121;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        table.mui-btn>tr>td,table.mui-btn>tbody>tr>td{border-radius:3px}
        table.mui-btn>tr>td>a,table.mui-btn>tbody>tr>td>a{font-weight:500;font-size:14px;color:#212121;line-height:14px;letter-spacing:.03em;text-transform:uppercase;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent;display:inline-block;text-decoration:none;text-align:center;border-radius:3px;padding:10px 25px;background-color:transparent}
        table.mui-btn.mui-btn--primary>tr>td,table.mui-btn.mui-btn--primary>tbody>tr>td{background-color:#2196f3}
        table.mui-btn.mui-btn--primary>tr>td>a,table.mui-btn.mui-btn--primary>tbody>tr>td>a{color:#FFF;border-top:1px solid #2196f3;border-left:1px solid #2196f3;border-right:1px solid #2196f3;border-bottom:1px solid #2196f3}
        table.mui-btn.mui-btn--primary.mui-btn--raised>tr>td>a,table.mui-btn.mui-btn--primary.mui-btn--raised>tbody>tr>td>a{border-top:1px solid #51adf6;border-left:1px solid #2196f3;border-right:1px solid #2196f3;border-bottom:2px solid #0a6ebd}
        table.mui-btn.mui-btn--primary.mui-btn--flat>tr>td,table.mui-btn.mui-btn--primary.mui-btn--flat>tbody>tr>td{background-color:transparent}
        table.mui-btn.mui-btn--primary.mui-btn--flat>tr>td>a,table.mui-btn.mui-btn--primary.mui-btn--flat>tbody>tr>td>a{color:#2196f3;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        table.mui-btn.mui-btn--danger>tr>td,table.mui-btn.mui-btn--danger>tbody>tr>td{background-color:#f44336}
        table.mui-btn.mui-btn--danger>tr>td>a,table.mui-btn.mui-btn--danger>tbody>tr>td>a{color:#FFF;border-top:1px solid #f44336;border-left:1px solid #f44336;border-right:1px solid #f44336;border-bottom:1px solid #f44336}
        table.mui-btn.mui-btn--danger.mui-btn--raised>tr>td>a,table.mui-btn.mui-btn--danger.mui-btn--raised>tbody>tr>td>a{border-top:1px solid #f77066;border-left:1px solid #f44336;border-right:1px solid #f44336;border-bottom:2px solid #d2190b}
        table.mui-btn.mui-btn--danger.mui-btn--flat>tr>td,table.mui-btn.mui-btn--danger.mui-btn--flat>tbody>tr>td{background-color:transparent}
        table.mui-btn.mui-btn--danger.mui-btn--flat>tr>td>a,table.mui-btn.mui-btn--danger.mui-btn--flat>tbody>tr>td>a{color:#f44336;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        table.mui-btn.mui-btn--dark>tr>td,table.mui-btn.mui-btn--dark>tbody>tr>td{background-color:#424242}
        table.mui-btn.mui-btn--dark>tr>td>a,table.mui-btn.mui-btn--dark>tbody>tr>td>a{color:#FFF;border-top:1px solid #424242;border-left:1px solid #424242;border-right:1px solid #424242;border-bottom:1px solid #424242}
        table.mui-btn.mui-btn--dark.mui-btn--raised>tr>td>a,table.mui-btn.mui-btn--dark.mui-btn--raised>tbody>tr>td>a{border-top:1px solid #5c5c5c;border-left:1px solid #424242;border-right:1px solid #424242;border-bottom:2px solid #1c1c1c}
        table.mui-btn.mui-btn--dark.mui-btn--flat>tr>td,table.mui-btn.mui-btn--dark.mui-btn--flat>tbody>tr>td{background-color:transparent}
        table.mui-btn.mui-btn--dark.mui-btn--flat>tr>td>a,table.mui-btn.mui-btn--dark.mui-btn--flat>tbody>tr>td>a{color:#424242;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        table.mui-btn.mui-btn--accent>tr>td,table.mui-btn.mui-btn--accent>tbody>tr>td{background-color:#ff4081}
        table.mui-btn.mui-btn--accent>tr>td>a,table.mui-btn.mui-btn--accent>tbody>tr>td>a{color:#FFF;border-top:1px solid #ff4081;border-left:1px solid #ff4081;border-right:1px solid #ff4081;border-bottom:1px solid #ff4081}
        table.mui-btn.mui-btn--accent.mui-btn--raised>tr>td>a,table.mui-btn.mui-btn--accent.mui-btn--raised>tbody>tr>td>a{border-top:1px solid #ff73a3;border-left:1px solid #ff4081;border-right:1px solid #ff4081;border-bottom:2px solid #f30053}
        table.mui-btn.mui-btn--accent.mui-btn--flat>tr>td,table.mui-btn.mui-btn--accent.mui-btn--flat>tbody>tr>td{background-color:transparent}
        table.mui-btn.mui-btn--accent.mui-btn--flat>tr>td>a,table.mui-btn.mui-btn--accent.mui-btn--flat>tbody>tr>td>a{color:#ff4081;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:1px solid transparent}
        a.mui-btn--small,table.mui-btn--small>tr>td>a,table.mui-btn--small>tbody>tr>td>a{font-size:13px;padding:7.8px 15px}
        a.mui-btn--large,table.mui-btn--large>tr>td>a,table.mui-btn--large>tbody>tr>td>a{font-size:14px;padding:19px 25px}
        .mui-container,.mui-container-fixed{max-width:600px;display:block;margin:0 auto;clear:both;text-align:left;padding-left:15px;padding-right:15px}
        .mui-container-fixed{width:600px}
        .mui-divider{display:block;height:1px;background-color:#e0e0e0}
        .mui--divider-top{border-top:1px solid #e0e0e0}
        .mui--divider-bottom{border-bottom:1px solid #e0e0e0}
        .mui--divider-left{border-left:1px solid #e0e0e0}
        .mui--divider-right{border-right:1px solid #e0e0e0}
        .mui-panel{padding:15px;border-radius:0;background-color:#FFF;border-top:1px solid #ededed;border-left:1px solid #e6e6e6;border-right:1px solid #e6e6e6;border-bottom:2px solid #d4d4d4}
        .mui--text-left{text-align:left}
        .mui--text-right{text-align:right}
        .mui--text-center{text-align:center}
        .mui--text-justify{text-align:justify}
        .mui-image--fix{display:block}
        .mui--text-dark{color:#212121}
        .mui--text-dark-secondary{color:#757575}
        .mui--text-dark-hint{color:#9e9e9e}
        .mui--text-light{color:#FFF}
        .mui--text-light-secondary{color:#b3b3b3}
        .mui--text-light-hint{color:gray}
        .mui--text-accent{color:#ff4081}
        .mui--text-accent-secondary{color:#ff82ad}
        .mui--text-accent-hint{color:#ffa6c4}
        .mui--text-black{color:#000}
        .mui--text-white{color:#FFF}
        .mui--text-danger{color:#f44336}
        .mui--text-display4{font-weight:300;font-size:112px;line-height:112px}
        .mui--text-display3{font-weight:400;font-size:56px;line-height:56px}
        .mui--text-display2{font-weight:400;font-size:45px;line-height:48px}
        .mui--text-display1,h1{font-weight:400;font-size:34px;line-height:40px}
        .mui--text-headline,h2{font-weight:400;font-size:24px;line-height:32px}
        .mui--text-title,h3{font-weight:400;font-size:20px;line-height:28px}
        .mui--text-subhead,h4{font-weight:400;font-size:16px;line-height:24px}
        .mui--text-body2,h5{font-weight:500;font-size:14px;line-height:24px}
        .mui--text-body1{font-weight:400;font-size:14px;line-height:20px}
        .mui--text-caption{font-weight:400;font-size:12px;line-height:16px}
        .mui--text-menu{font-weight:500;font-size:13px;line-height:17px}
        .mui--text-button{font-weight:500;font-size:14px;line-height:18px;text-transform:uppercase}
      </style>
    </head>
    <body>
      <table class='mui-body' cellpadding='0' cellspacing='0' border='0'>
        <tr>
          <td>
            <center>
              <!--[if mso]><table><tr><td class='mui-container-fixed'><![endif]-->
              <div class='mui-container'>

              <div>
                <a href="#" class="mui-btn mui-btn--primary">Button</a>
                <a href='#' class='mui-btn mui-btn--raised'>Button</a>
                <a href='#' class='mui-btn mui-btn--raised mui-btn--primary'>Button</a>
                <a href='#' class='mui-btn mui-btn--raised mui-btn--danger'>Button</a>
                <a href='#' class='mui-btn mui-btn--raised mui-btn--accent'>Button</a>
              </div>

              </div>
              <!--[if mso]></td></tr></table><![endif]-->
            </center>
          </td>
        </tr>
      </table>
    </body>
  </html>
@mathiasleroy mathiasleroy changed the title HTML buttons are not colored EMAIL buttons are not colored May 28, 2018
@amorey
Copy link
Member

amorey commented May 28, 2018

To render HTML emails correctly you need to inline the CSS in mui-email-inline.css. The output should look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width">
    <style>#outlook a{padding:0}.ExternalClass,.ReadMsgBody{width:100%}.ExternalClass,.ExternalClass div,.ExternalClass font,.ExternalClass p,.ExternalClass span,.ExternalClass td{line-height:100%}.mui-container-fixed{width:600px;display:block;margin:0 auto;clear:both;text-align:left;padding-left:15px;padding-right:15px}</style>
  </head>
  <body style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #FFF; color: #212121; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, 'Trebuchet MS'; font-size: 14px; font-weight: 400; letter-spacing: 0.001em; line-height: 1.429; margin: 0; min-width: 100%; padding: 0; width: 100% !important;">
    <table class="mui-body" cellpadding="0" cellspacing="0" border="0" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #FFF; border-collapse: collapse; border-spacing: 0; color: #212121; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, 'Trebuchet MS'; font-size: 14px; font-weight: 400; height: 100%; letter-spacing: 0.001em; line-height: 1.429; margin: 0; mso-table-lspace: 0pt; mso-table-rspace: 0pt; padding: 0; width: 100%;">
      <tr>
        <td style="-moz-hyphens: auto; -ms-text-size-adjust: 100%; -webkit-hyphens: auto; -webkit-text-size-adjust: 100%; border-collapse: collapse !important; hyphens: auto; mso-table-lspace: 0pt; mso-table-rspace: 0pt; padding: 0; text-align: left; word-break: break-word;">
          <center>
            <!--[if mso]><table><tr><td class="mui-container-fixed"><![endif]-->
            <div class="mui-container" style="clear: both; display: block; margin: 0 auto; max-width: 600px; padding-left: 15px; padding-right: 15px; text-align: left;">
              <div>
                <a href="#" class="mui-btn mui-btn--primary" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #2196F3; border-bottom: 1px solid #2196F3; border-left: 1px solid #2196F3; border-radius: 3px; border-right: 1px solid #2196F3; border-top: 1px solid #2196F3; color: #FFF; cursor: pointer; display: inline-block; font-size: 14px; font-weight: 500; letter-spacing: 0.03em; line-height: 14px; padding: 10px 25px; text-align: center; text-decoration: none; text-transform: uppercase; white-space: nowrap;">Button</a>
                <a href="#" class="mui-btn mui-btn--raised" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: transparent; border-bottom: 2px solid #bababa; border-left: 1px solid #e6e6e6; border-radius: 3px; border-right: 1px solid #e6e6e6; border-top: 1px solid #f2f2f2; color: #212121; cursor: pointer; display: inline-block; font-size: 14px; font-weight: 500; letter-spacing: 0.03em; line-height: 14px; padding: 10px 25px; text-align: center; text-decoration: none; text-transform: uppercase; white-space: nowrap;">Button</a>
                <a href="#" class="mui-btn mui-btn--raised mui-btn--primary" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #2196F3; border-bottom: 2px solid #0a6ebd; border-left: 1px solid #2196F3; border-radius: 3px; border-right: 1px solid #2196F3; border-top: 1px solid #51adf6; color: #FFF; cursor: pointer; display: inline-block; font-size: 14px; font-weight: 500; letter-spacing: 0.03em; line-height: 14px; padding: 10px 25px; text-align: center; text-decoration: none; text-transform: uppercase; white-space: nowrap;">Button</a>
                <a href="#" class="mui-btn mui-btn--raised mui-btn--danger" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #F44336; border-bottom: 2px solid #d2190b; border-left: 1px solid #F44336; border-radius: 3px; border-right: 1px solid #F44336; border-top: 1px solid #f77066; color: #FFF; cursor: pointer; display: inline-block; font-size: 14px; font-weight: 500; letter-spacing: 0.03em; line-height: 14px; padding: 10px 25px; text-align: center; text-decoration: none; text-transform: uppercase; white-space: nowrap;">Button</a>
                <a href="#" class="mui-btn mui-btn--raised mui-btn--accent" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #FF4081; border-bottom: 2px solid #f30053; border-left: 1px solid #FF4081; border-radius: 3px; border-right: 1px solid #FF4081; border-top: 1px solid #ff73a3; color: #FFF; cursor: pointer; display: inline-block; font-size: 14px; font-weight: 500; letter-spacing: 0.03em; line-height: 14px; padding: 10px 25px; text-align: center; text-decoration: none; text-transform: uppercase; white-space: nowrap;">Button</a>
              </div>
            </div>
            <!--[if mso]></td></tr></table><![endif]-->
          </center>
        </td>
      </tr>
    </table>
  </body>
</html>

@mathiasleroy
Copy link
Author

mathiasleroy commented May 30, 2018

Which tool did you use ? I used https://inliner.cm/ wich seem to be the best for every other elements than buttons (panels etc)

But with inliner.cm,

<a href="#" class="mui-btn--primary mui-btn">Button</a>

becomes

<a href="#" class="mui-btn--primary mui-btn" style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;cursor:pointer;white-space:nowrap;font-weight:500;font-size:14px;color:#212121;line-height:14px;letter-spacing:0.03em;text-transform:uppercase;border-top-width:1px;border-top-style:solid;border-top-color:#FFF;border-left-width:1px;border-left-style:solid;border-left-color:#FFF;border-right-width:1px;border-right-style:solid;border-right-color:#FFF;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#FFF;background-color:transparent;display:inline-block;text-decoration:none;text-align:center;border-radius:3px;padding-top:10px;padding-bottom:10px;padding-right:25px;padding-left:25px;" >Button</a>

background-color:transparent;
I guess because a.mui-btn{background-color: transparent;}

these 3 are much worse :
http://premailer.dialect.ca/
https://templates.mailchimp.com/resources/inline-css/
https://inlinestyler.torchbox.com/styler/convert/

@amorey
Copy link
Member

amorey commented May 30, 2018

The MUI website is written in Python and uses premailer and the MUI source code example generator uses gulp-inline-css. Here's the gulp code block that inlines the source code's email example files:
https://github.com/muicss/mui/blob/master/gulpfile.js#L420-L428

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

No branches or pull requests

2 participants