Search code examples
htmlcsssvgtailwind-css

TailwindCSS: SVG icon won't resize properly


I have been trying to resize the icon in this example.

<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.2/tailwind.min.css" rel="stylesheet"/>
<div class="bg-indigo-dark">
  <div class="flex text-grey-lighter">
    <svg class="flex-no-shrink fill-current" fill="none" xmlns="http://www.w3.org/2000/svg"
         viewBox="0 0 100 100" width="100px" height="100px">
      <path d="M5 5a5 5 0 0 1 10 0v2A5 5 0 0 1 5 7V5zM0 16.68A19.9 19.9 0 0 1 10 14c3.64 0 7.06.97 10 2.68V20H0v-3.32z"/>
    </svg>
    <div class="leading-normal">
      Some demo text
    </div>
  </div>
</div>

But, whatever I try I can't get the svg to resize. What am I doing wrong?


Solution

  • To resize the icon, resize the viewBox

    <link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.2/tailwind.min.css" rel="stylesheet"/>
    
    <div class="bg-indigo-dark">
      <div class="flex text-grey-lighter">
    
        <svg 
          class="flex-no-shrink fill-current" 
          fill="none" 
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 80 80"  
          width="100px" 
          height="100px"
        >
          <path d="M5 5a5 5 0 0 1 10 0v2A5 5 0 0 1 5 7V5zM0 16.68A19.9 19.9 0 0 1 10 14c3.64 0 7.06.97 10 2.68V20H0v-3.32z"/>
        </svg>
    
        <div class="leading-normal">
          Some demo text
        </div>
      </div>
    </div>