0

I am working on sendgrid dynamic template HTML code. I want that slider to be filled with dynamic value by go lang code. In sendgrid, when i see the colour of the slider then colours are showing as it should, you can see it in below image:

enter image description here

But when i received email from test then i am gettting slider in grey colour?

enter image description here

Here is my HTML code for this:

<!DOCTYPE html>
<html>
  <body style="margin: 0; padding: 20px; font-family: Arial, sans-serif;">
    <table cellpadding="0" cellspacing="0" border="0" width="100%" style="max-width: 400px; margin: 0 auto;">
      <tr>
        <td align="center" style="padding: 20px 0;">
          <input type="range" min="0" max="100" value="80" class="custom-slider" disabled="" style="
              -webkit-appearance: none !important;
              -moz-appearance: none !important;
              appearance: none !important;
              width: 100% !important;
              height: 8px !important;
              background: linear-gradient(to right, #FF8444 80%, #3C2A20 80%) !important;
              border-radius: 5px !important;
              outline: none !important;
              border: none !important;
              box-shadow: none !important;
              color: #FF8444 !important;
              accent-color: #FF8444 !important;
            ">
        </td>
      </tr>
    </table>
  </body>
</html>

How i can add same colour in email as it is in sendgrid?

1 Answer 1

0

so you're trying to get that slider to show a colored fill in an email the same way it does in SendGrid's preview. The tricky bit is that most email clients don’t support or custom CSS for form elements. They strip out or ignore those styles completely once the email gets sent. If you're seeing it work in the template editor but not in the inbox that's completely normal behavior. That visual styling you're seeing is only happening because SendGrid uses a browser environment to preview not a real email client. To force the look, I’d suggest replacing the actual slider with a styled div or even a table cell that visually looks like a slider bar. Well basically fake it with static HTML and CSS. You can make the filled portion with a div that has a linear gradient background or two nested boxes one for the base and another for the filled part sized to the value you want. If you're injecting the value from Golang you can set the width dynamically like this:

<div style="width: 100px; height: 8px; background-color: #3C2A20; border-radius: 5px;">
  <div style="width: 80px; height: 8px; background-color: #FF8444; border-radius: 5px;"></div>
</div>

Just generate the 80px part in Go based on your value. That way the slider looks dynamic but still plays nice in email clients. Hope that helps good luck getting that part polished up.

Sign up to request clarification or add additional context in comments.

1 Comment

Hey, Thanks for your answer. I have already tried with the above method but problem with above method is i didn't get the circle along with the progress filled as shown in the above image. When it is filled with 100% then with above method it is hard to represent the progress bar as filled with 100% as whole progrees bar looks orange in that case. I tried to add circle using div and in sendgrid is showing perfectly but again in email it doesn't work as i use position:"absolute" and "relative" and it doesn't work for me in email client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.