Tailwindcss How To Create Rectangle

Tailwindcss How To Create Rectangle

Table of Contents

In Tailwind CSS, you can create rectangles by using the utility classes provided by Tailwind CSS to define the width and height of an element. Here’s a basic example of how you can create a rectangle:

Example

<div class="w-64 h-32 bg-blue-500"></div>

tailwind css rectangle

  1. w-64 sets the width of the element to 16rem (64/4 = 16). Tailwind CSS uses a 4-point spacing scale by default.
  2. h-32 sets the height of the element to 8rem (32/4 = 8).
  3. bg-blue-500 sets the background color of the element to a shade of blue with a class generated based on the configured color palette in your Tailwind CSS configuration file. bg-blue-500 specifically refers to the shade at index 500 in the blue color scale.

You can adjust the w- and h- classes to set the desired width and height for your rectangle, and you can also customize the background color by using different color classes.

Here’s another example that creates a rectangle with a different width, height, and background color:

 

<div class="w-40 h-20 bg-red-400"></div>

 

Leave a Comment

Your email address will not be published. Required fields are marked *

No data found.