skip to Main Content

I’m trying to reproduce this heart-shaped "like" button:

Inactive state at the top, hovering at the bottom

The hover has to be animated with a transition, like this.

I’ve tried using FontAwesome and Material Icons, but I can’t figure out how to do a proper transition with them. background-color leaves the borders of the icon.

2

Answers


  1. I figure 2 ways of doing it, the first one:

    In this way, you have to "draw" the heart manually with SVG, and then work on hover with css.

    .icon-container {
          display: inline-block;
            position: relative;
            overflow: hidden;
            width: 150px;
            height: 150px;
      }
    
      .icon {
        width: 100%;
        height: 100%;
        fill: white; 
        stroke: black; 
        stroke-width: 0.5; 
        transition: fill 0.3s ease;
       }
      .icon-container:hover .icon path {
    fill: red;
    stroke: red;
      }
    <body>
      <div class="icon-container">
       <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
          <path d="M12 21.35l-1.45-1.32C5.4 16.36 2 13.28 2 9.5 2 6.42 4.42 4 7.5 4c1.74 0 3.41.81 4.5 2.09C15.09 4.81 16.76 4 18.5 4 21.58 4 24 6.42 24 9.5c0 3.78-3.4 6.86-8.55 10.54L12 21.35z"/>
        </svg>
      </div>
    </body>

    The second one:

    That’s the one i prefer, but you have to work with a PNG who have the transparency inside the heart, or you’ll get (as the example) the entire image container coloured.

    .icon-container {
        display: inline-block;
        position: relative;
        overflow: hidden;
        width: 150px;
        height: 150px;
      }
    
      .icon {
        width: 100%;
        height: 100%;
        background-image: url('https://cdn-icons-png.flaticon.com/512/1077/1077035.png');
        background-size: cover;
        transition: background-color 0.3s ease;
      }
    
      .icon-container:hover .icon {
        background-color: red;
      }
    <body>
      <div class="icon-container">
        <div class="icon"></div>
      </div>
    </body>

    Hope it helps!

    Login or Signup to reply.
  2. For icons like these, using Scalable Vector Graphics (SVGs) is ideal for a multitude of reasons, but in this specific case especially so because of the fact you can use CSS to style individual elements of the SVG.

    .heart .heart-fill {
      /* notice the defined alpha component. you could also use opacity though, of course */
      fill: #00000000;
    }
    
    .heart .heart-outline {
      fill: #000000;
    }
    
    .heart .heart-outline,
    .heart .heart-fill {
      transition-property: fill;
      transition-duration: 0.3s;
      transition-timing-function: ease-in-out;
    }
    
    #heart {
      width: 300px;
      height: auto;
    }
    
    #heart:hover {
      cursor: pointer;
    }
    
    
    /* this uses the bounding box of the whole svg for hovering, which is perfectly fine for small buttons, but may be slightly problematic for using this svg in a larger size (.heart-fill:hover + .heart-outline should work for that case though) */
    #heart:hover .heart-fill,
    #heart:hover .heart-outline {
      fill: #ff0000;
    }
    <!-- container -->
    <div id="heart">
      <!-- source: https://www.svgrepo.com/svg/13666/heart -->
      <!-- edited with Adobe Illustrator to add the solid section -->
      <svg class="heart" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 800 800" style="enable-background:new 0 0 800 800;" xml:space="preserve">
    <path class="heart-fill" d="M735.4,113.6C693.5,71.7,638,48.8,578.8,48.8s-114.8,23.1-156.7,65l-21.9,21.9L378,113.5c-41.9-41.9-97.7-65.1-156.9-65.1
        c-59,0-114.6,23.1-156.4,64.8C22.9,155-0.2,210.6,0,269.8C0,329,23.2,384.5,65.1,426.4l318.5,318.5c4.4,4.4,10.3,6.8,16.1,6.8
        s11.7-2.2,16.1-6.6l319.2-318c41.9-41.9,65-97.5,65-156.7C800.2,211.2,777.3,155.5,735.4,113.6z"/>
    <path class="heart-outline" d="M735.4,113.6C693.5,71.7,638,48.8,578.8,48.8c-59.2,0-114.8,23.1-156.7,65l-21.9,21.9L378,113.5
        c-41.9-41.9-97.7-65.1-156.9-65.1c-59,0-114.6,23.1-156.4,64.8C22.9,155-0.2,210.6,0,269.8C0,329,23.2,384.5,65.1,426.4l318.5,318.5
        c4.4,4.4,10.3,6.8,16.1,6.8c5.8,0,11.7-2.2,16.1-6.6l319.2-318c41.9-41.9,65-97.5,65-156.7C800.2,211.2,777.3,155.5,735.4,113.6z
         M702.8,394.7L399.7,696.5L97.4,394.1c-33.2-33.2-51.6-77.3-51.6-124.3s18.1-91.1,51.4-124.1c33.1-33.1,77.2-51.4,124-51.4
        c47,0,91.2,18.3,124.5,51.6l38.3,38.3c9,9,23.4,9,32.4,0l38-38c33.2-33.2,77.5-51.6,124.3-51.6c46.8,0,90.9,18.3,124.1,51.4
        c33.2,33.2,51.4,77.3,51.4,124.3C754.4,317.3,736.1,361.4,702.8,394.7z"/>
    </svg>
    </div>

    The only downside to this is that you need to actually include the svg tag everywhere, including all it’s data. The styles can be in an external stylesheet though. Including the SVG as an img or an object would prevent you from interacting with it’s styles.

    You also need to have two separate elements (the outline/border, and the filled in shape) inside the SVG, as CSS border or outline do not get applied to those elements, but their bounding box instead. There is of course the stroke attribute that would work fine on the filled shape element, but you have no control over the direction of it (like applying the stroke inside the path), so it’s not ideal.

    The other solution would be using normal rasterized images stacked on top of one another and styling their opacity:

    .heart-fill {
      opacity: 0;
    }
    
    .heart-outline {
      opacity: 1;
    }
    
    .heart-fill, .heart-outline {
      transition-property: opacity;
      transition-duration: 0.3s;
      transition-timing-function: ease-in-out;
    }
    
    #heart {
      width: 300px;
      height: auto;
    
      position: relative;
    }
    
    #heart .heart-outline,
    #heart .heart-fill {
      width: 100%;
      height: auto;
    }
    
    #heart .heart-fill {
      position: absolute;
      top: 0;
      left: 0;
      
      pointer-events: none;
      
      z-index: 1;
    }
    
    #heart:hover {
      cursor: pointer;
    }
    
    #heart:hover .heart-fill {
      opacity: 1;
    }
    
    #heart:hover .heart-outline {
      opacity: 0;
    }
    <!-- container -->
    <div id="heart">
      <!-- source: https://static.thenounproject.com/png/2175990-200.png -->
      <!-- edited with Adobe Photoshop to create the border version, then encoded as inline Base64 png -->
      <img class="heart-fill" type="image/png" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF+mlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOW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MXgwTy5fcRL4m3cp7SrYeV492HwQLxxiorZ01QmMgeDBpICrTC3xywTaYCHJ7o/gseSALT9sBZB20TaQ/0JDCtYoF8edXvB9DnwG08dUJvArWT2XtRACkheUQkNk4cdZPdd9EAEYlljiM2ICKxTHHECEQklhmOWIGIxDLBETMQkdiU44gdiEhsSnFUAhCRiGMq91ZFABGJOAQiEssaR6UBEYk4BCIScWS4lyoSiEjEIRCRiEMgIhFHjjiqAYhIxCEQkYhDICIRh0BEIo5wcFQjEJGIQyAiEYdARCIOgYhEHAIRiTgEEvIiiEQcAhGJOAQiEnEIRCTiEIhIxCEQkYhDINECEUmV4xCISMQhEJGIQyAiEYdARCIOgYhEHAIRiTgEUslARFIFOAQiEnEIRCTiEIhIxCEQkYhDICIRh0BEIg6BVCuQSkRSlTgEIhJxCEQk4hCISMQhEJGIQyAiEYdARCIOgQgkLiTiEIhIxCEQkYhDICIRh0BEIg6BWA5IxCEQkYhDICIRh0BEIg6B2FQiEYdARCIOgYhEHAKxsiARh0BEIg6B2PiQiEMg1Yykrh26iyPAGIJ0JxxPoNa1EkhV9wY8vw0OfQB9ndC3DQ4ugedcm1iBmFVJLoKZQMwEYiYQM4GYCcRMIGYCMROImUDMTCBmAjETiJlAzARiJhAzgZgJxEwgZlXefwFc55dAGdMZpQAAAABJRU5ErkJggg==" />
      <img class="heart-outline" type="image/png" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF+mlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPi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HRBwCEUk3SMQhEJF0g0QcAhHJgZGIQyAiSTniEIhIxCEQkYhDICIRh0A8skQiDoGIRBwCEYk4BOKRChJxCEQk4hCIRxwScQikaY82YAnQvh8Ye4HFQE/LJJBmP44B5oVPlHXA5cAYy1JSIMY0SyyCMQIxRiDGCMQYgRgjEGMEYoxAjBGIMQIxxgjEGIEYIxBjBGKMQIwRiDECMUYgxgjEmCbPfwG89IKm2PNMXgAAAABJRU5ErkJggg==" />
    </div>

    I’d definitely recommend using the SVG approach though, as it is just so much more flexible, and also has the advantage of being a vector image. Adding a gradient (like in your example) to the SVG would be as simple as adding a CSS linear-gradient to the background of the .heart-fill class. And you could of course animate that too.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search