Skip to content

Instantly share code, notes, and snippets.

@AnalyzePlatypus
Created February 20, 2022 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnalyzePlatypus/9db621764bfda3e3944b69da953912a9 to your computer and use it in GitHub Desktop.
Save AnalyzePlatypus/9db621764bfda3e3944b69da953912a9 to your computer and use it in GitHub Desktop.

Tailwind Icon Height sizes

These CSS classes will size any square SVG to match the default TailwindCSS font sizes. Great for mixing icons with text on buttons and headings.

The icon sizes were manually picked, so they match my taste. Your mileage may vary! I've also added sizes that are larger than Tailwind's max font size for really big icons in hero sections and the like

Enjoy!

Usage

  1. Add the styles to your stylesheet
  2. Use the classes on your SVGs like so:
<button class='flex flex-row items-center'>
   <span class='text-sm mr-2'>New item</span>
   <!-- This icon will be the same size as 'sm' font size -->
   <svg class='icon-sm'>...</svg>
</button>

Styles

.icon-10xl {
  height: 8rem;
}

.icon-9xl {
  height: 7rem;
}

.icon-8xl {
  height: 6rem;
}

.icon-7xl {
  height: 5rem;
}

.icon-6xl {
  height: 4.5rem;
}

.icon-5xl {
  height: 3.25rem;
}

.icon-4xl {
  height: 2.75rem;
}

.icon-3xl {
  height: 2.25rem;
}

.icon-2xl {
  height: 2rem;
}

.icon-xl {
  height: 1.75rem;
}

.icon-lg {
  height: 1.7rem;
}


.icon-md {
  height: 1.5rem;
}


.icon-sm {
  height: 1.2rem;
}

.icon-xs {
  height: 1rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment