TExcelTAD
Home › Tailwind CSS › Tailwind Cards

Tailwind Cards

A card is a self-contained box of related content: a product, a profile, a blog post. Cards are a great exercise because they combine layout, spacing, typography and effects in a small space.

A basic card

Part Typical classes
Container rounded-xl bg-white shadow-md or ring-1 ring-gray-200
Clipping overflow-hidden so media respects the rounded corners
Media aspect-video or h-32 with a gradient / image
Body p-5 or p-6
Title / text text-lg font-semibold / text-sm text-gray-600
Footer flex items-center justify-between border-t
html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="bg-gray-100 p-4">
  <article class="max-w-xs overflow-hidden rounded-xl bg-white shadow-md">
    <div class="flex h-24 items-center justify-center bg-linear-to-br from-sky-400 to-indigo-500 text-5xl">🏝️</div>
    <div class="p-4">
      <p class="text-xs font-semibold tracking-wide text-indigo-600 uppercase">Travel</p>
      <h3 class="mt-1 text-lg font-semibold text-gray-900">Ten quiet islands</h3>
      <p class="mt-1 text-sm text-gray-600">Beaches you can still have to yourself this summer.</p>
    </div>
  </article>
</body>
</html>

Product card with hover effect

group on the card lets the inner "image" zoom when the whole card is hovered.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="bg-stone-100 p-4">
  <a href="#" class="group block w-56 overflow-hidden rounded-2xl bg-white shadow-sm ring-1 ring-stone-200 transition hover:-translate-y-1 hover:shadow-xl">
    <div class="relative overflow-hidden">
      <div class="flex aspect-[4/3] items-center justify-center bg-linear-to-br from-amber-200 to-orange-300 text-6xl transition duration-500 group-hover:scale-110">🎧</div>
      <span class="absolute top-2 left-2 rounded-full bg-rose-500 px-2 py-0.5 text-xs font-bold text-white">-20%</span>
    </div>
    <div class="p-4">
      <h3 class="font-semibold text-stone-900">Studio Headphones</h3>
      <div class="mt-2 flex items-baseline gap-2">
        <span class="text-lg font-bold text-stone-900">$79</span>
        <span class="text-sm text-stone-400 line-through">$99</span>
        <span class="ml-auto text-sm text-amber-500">★ 4.8</span>
      </div>
    </div>
  </a>
</body>
</html>

Profile card

Centred content, an avatar with a ring, stats separated by dividers, and actions at the bottom.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="flex justify-center bg-slate-100 p-3">
  <div class="w-64 rounded-2xl bg-white p-5 text-center shadow-lg">
    <div class="mx-auto flex size-16 items-center justify-center rounded-full bg-violet-200 text-3xl ring-4 ring-violet-100">🧑‍💻</div>
    <h3 class="mt-2 font-bold text-slate-900">Minh Tran</h3>
    <p class="text-sm text-slate-500">Front-end developer</p>
    <div class="mt-3 grid grid-cols-3 divide-x divide-slate-200 text-sm">
      <div><p class="font-bold">42</p><p class="text-xs text-slate-500">Posts</p></div>
      <div><p class="font-bold">1.2k</p><p class="text-xs text-slate-500">Followers</p></div>
      <div><p class="font-bold">180</p><p class="text-xs text-slate-500">Following</p></div>
    </div>
    <div class="mt-3 flex gap-2">
      <button class="flex-1 rounded-lg bg-violet-600 py-1.5 text-sm font-semibold text-white hover:bg-violet-500">Follow</button>
      <button class="flex-1 rounded-lg py-1.5 text-sm font-semibold text-slate-700 ring-1 ring-slate-300 hover:bg-slate-50">Message</button>
    </div>
  </div>
</body>
</html>

Horizontal card that stacks on mobile

Use flex-col by default and sm:flex-row above 640px. Resize the preview to see it switch.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="bg-gray-100 p-4">
  <article class="flex flex-col overflow-hidden rounded-xl bg-white shadow sm:flex-row">
    <div class="flex h-24 items-center justify-center bg-linear-to-br from-emerald-400 to-teal-600 text-5xl sm:h-auto sm:w-40 sm:shrink-0">🌱</div>
    <div class="p-4">
      <p class="text-xs text-gray-500">5 min read · Gardening</p>
      <h3 class="mt-1 font-semibold text-gray-900">Growing herbs on a windowsill</h3>
      <p class="mt-1 line-clamp-2 text-sm text-gray-600">Basil, mint and parsley thrive indoors with a little light and the right pot. Here's everything you need to get started this weekend.</p>
    </div>
  </article>
</body>
</html>

A responsive grid of cards

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="bg-gray-100 p-4">
  <div class="grid grid-cols-2 gap-3 md:grid-cols-4">
    <div class="rounded-xl bg-white p-4 shadow-sm"><p class="text-2xl">📈</p><p class="mt-1 text-xs text-gray-500">Revenue</p><p class="text-lg font-bold">$12.4k</p></div>
    <div class="rounded-xl bg-white p-4 shadow-sm"><p class="text-2xl">🛒</p><p class="mt-1 text-xs text-gray-500">Orders</p><p class="text-lg font-bold">318</p></div>
    <div class="rounded-xl bg-white p-4 shadow-sm"><p class="text-2xl">👤</p><p class="mt-1 text-xs text-gray-500">Visitors</p><p class="text-lg font-bold">9,021</p></div>
    <div class="rounded-xl bg-white p-4 shadow-sm"><p class="text-2xl">⭐</p><p class="mt-1 text-xs text-gray-500">Rating</p><p class="text-lg font-bold">4.9</p></div>
  </div>
</body>
</html>

Tip: Make cards in a grid the same height automatically: grid items stretch by default, and flex flex-col + mt-auto on the footer pins the footer to the bottom.

Test yourself

Why add overflow-hidden to a card with rounded-xl?

  1. To hide the shadow
  2. So child media is clipped to the rounded corners
  3. To enable scrolling
  4. It makes the card responsive

Which setup makes an inner element zoom when the *card* is hovered?

  1. hover:scale-110 on the inner element
  2. group on the card and group-hover:scale-110 on the inner element
  3. peer on the inner element
  4. scale-110 on the card

A card should be stacked on phones and horizontal from 640px. Which classes?

  1. flex flex-row sm:flex-col
  2. flex flex-col sm:flex-row
  3. grid sm:block
  4. flex max-sm:flex-row