shlogg · Early preview
Jetthoughts Dev @jetthoughts

Drawing Triangles In TailwindCSS With Borders

Draw a triangle in TailwindCSS using borders: set width and height to 0, then use top, left, right, and bottom borders to create the shape. Adjust border widths for different triangles.

In this post, we are going to see four examples of how to draw a triangle in TailwindCSS using borders.

  
  
  Triangle Down

Triangle is one of the simplest shapes in geometry. You can draw it with three straight lines and a couple of angles.

Set a width and height of 0 by: w-0 and h-0
Set the top border to have the full height and color by: border-t-[75px] border-t-red-500
Set the side borders to half the width with the color transparent by: border-l-[50px] border-l-transparent and border-r-[50px] border-r-transparent


<div class="w-0 h-0 
  border-l-[50px] border-l-transparent
  border-...