Open In App

How to Create a Rounded Card in Tailwind CSS ?

Last Updated : 11 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A rounded card is a design used in web development, featuring rounded corners and typically containing content or information within a defined boundary. To create a rounded card in Tailwind CSS, use the rounded utility class along with the bg-white and shadow-md classes for a clean, rounded look.

Syntax:

<div class="rounded bg-white shadow-md p-4">
<!-- Your card content here -->
</div>

Rounded Classes

ClassDescription
rounded-noneNo rounded corners.
rounded-smSmall rounded corners.
roundedMedium rounded corners.
rounded-mdMedium rounded corners (same as rounded).
rounded-lgLarge rounded corners.
rounded-xlExtra-large rounded corners.
rounded-2xlExtra-extra-large rounded corners.
rounded-3xlExtra-extra-extra-large rounded corners.
rounded-fullFully rounded corners, creating a circle if applied to a square element (e.g., a button).
rounded-tOnly the top corners are rounded.
rounded-rOnly the right corners are rounded.
rounded-bOnly the bottom corners are rounded.
rounded-lOnly the left corners are rounded.
rounded-tlOnly the top-left corner is rounded.
rounded-trOnly the top-right corner is rounded.
rounded-brOnly the bottom-right corner is rounded.
rounded-blOnly the bottom-left corner is rounded.

Example 1: Implementation to design different types of rounded cards.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>Rounded Card</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="text-center mx-4 space-y-4">
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1>

    <div class="mx-24 bg-green-400 
                text-justify px-12 rounded-full">
        <h3 class="text-2xl text-center">
              Full Rounded Corners
          </h3>
        <ul class="list-disc">
            <li>HTML</li>
            <li>CSS</li>
            <li>Javascript</li>
        </ul>
    </div>
    <div class="mx-24 bg-green-400 
                text-justify px-8 rounded-t-lg">
        <h3 class="text-2xl text-center">
              Top Rounded Corners
          </h3>
        <ul class="list-disc">
            <li>HTML</li>
            <li>CSS</li>
            <li>Javascript</li>
        </ul>
    </div>
    <div class="mx-24 bg-green-400 
                text-justify px-8 rounded-r-lg">
        <h3 class="text-2xl text-center">
              Right Rounded Corners
          </h3>
        <ul class="list-disc">
            <li>HTML</li>
            <li>CSS</li>
            <li>Javascript</li>
        </ul>
    </div>
    <div class="mx-24 bg-green-400 
                text-justify px-8 rounded-b-lg">
        <h3 class="text-2xl text-center">
              Bottom Rounded Corners
          </h3>
        <ul class="list-disc">
            <li>HTML</li>
            <li>CSS</li>
            <li>Javascript</li>
        </ul>
    </div>
    <div class="mx-24 bg-green-400 
                text-justify px-8 rounded-l-lg">
        <h3 class="text-2xl text-center">
              Left Rounded Corners
          </h3>
        <ul class="list-disc">
            <li>HTML</li>
            <li>CSS</li>
            <li>Javascript</li>
        </ul>
    </div>
</body>

</html>

Output:

Screenshot-2024-02-29-102737

Example 2: Implementation to design rounded card with hover effect.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>Rounded Card</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="text-center mx-4 space-y-4">
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1>
    <div class="mx-24 bg-green-400 text-justify 
                px-14 rounded hover:rounded-full">
        <h3 class="text-2xl text-center">
              Rounded Corners with hover Effect
          </h3>
        <ul class="list-disc">
            <li>HTML</li>
            <li>CSS</li>
            <li>Javascript</li>
        </ul>
    </div>
</body>

</html>

Output:

rtg


Next Article

Similar Reads