Published on

A Complete Guide To Make A Post/Article Card With Tailwind CSS

Tags
Post/Article Card

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of Post/Article Card ui component

Simple article or a post card with an image

Why use Tailwind CSS to create a Post/Article Card ui component?

  • It can make the building process of Post/Article Card ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Post/Article Card component file.

The preview of Post/Article Card ui component

Free download of the Post/Article Card's source code

The source code of Post/Article Card ui component

<div class="mx-auto px-4 py-8 max-w-xl my-20">
        <div class="bg-white shadow-2xl rounded-lg mb-6 tracking-wide" >
            <div class="md:flex-shrink-0">
                <img src="https://ik.imagekit.io/q5edmtudmz/post1_fOFO9VDzENE.jpg" alt="mountains" class="w-full h-64 rounded-lg rounded-b-none">
            </div>
            <div class="px-4 py-2 mt-2">
                <h2 class="font-bold text-2xl text-gray-800 tracking-normal">My Amaizing Journey to the Mountains.</h2>
                    <p class="text-sm text-gray-700 px-2 mr-1">
                        Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempora reiciendis ad architecto at aut placeat quia, minus dolor praesentium officia maxime deserunt porro amet ab debitis deleniti modi soluta similique...
                    </p>
                    <div class="flex items-center justify-between mt-2 mx-6">
                        <a href="#" class="text-blue-500 text-xs -ml-3 ">Show More</a>
                        <a href="#" class="flex text-gray-700">
                            <svg fill="none" viewBox="0 0 24 24" class="w-6 h-6 text-blue-500" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"/>
                            </svg>
                            5
                        </a>
                    </div>
                <div class="author flex items-center -ml-3 my-3">
                    <div class="user-logo">
                        <img class="w-12 h-12 object-cover rounded-full mx-4  shadow" src="https://images.unsplash.com/photo-1492562080023-ab3db95bfbce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=731&q=80" alt="avatar">
                    </div>
                    <h2 class="text-sm tracking-tighter text-gray-900">
                        <a href="#">By Mohammed Ibrahim</a> <span class="text-gray-600">21 SEP 2015.</span>
                    </h2>
                </div>
            </div>
        </div>
    </div>

How to create a Post/Article Card with Tailwind CSS?

Install tailwind css of verion 1.4.6

Use the link html tag to import the stylesheet of Tailwind CSS of the version 1.4.6

<link href=https://unpkg.com/[email protected]/dist/tailwind.min.css rel="stylesheet">

All the unility class needed to create a Post/Article Card component

  • mx-auto
  • px-4
  • py-8
  • max-w-xl
  • my-20
  • bg-white
  • mb-6
  • md:flex-shrink-0
  • w-full
  • h-64
  • py-2
  • mt-2
  • text-2xl
  • text-gray-800
  • text-sm
  • text-gray-700
  • px-2
  • mr-1
  • flex
  • mx-6
  • text-blue-500
  • text-xs
  • -ml-3
  • w-6
  • h-6
  • my-3
  • w-12
  • h-12
  • mx-4
  • text-gray-900
  • text-gray-600

31 steps to create a Post/Article Card component with Tailwind CSS

  1. Control the horizontal margin of an element to auto using the mx-auto utilities.

  2. Control the horizontal padding of an element to 1rem using the px-4 utilities.

  3. Control the vertical padding of an element to 2rem using the py-8 utilities.

  4. Set the maximum width/height of an element using the max-w-xl utilities.

  5. Control the vertical margin of an element to 5rem using the my-20 utilities.

  6. Control the background color of an element to white using the bg-white utilities.

  7. Control the margin on bottom side of an element to 1.5rem using the mb-6 utilities.

  8. Use flex to create a block-level flex container at only medium screen sizes.

  9. Use w-full to set an element to a 100% based width.

  10. Use h-64 to set an element to a fixed height(16rem).

  11. Control the vertical padding of an element to 0.5rem using the py-2 utilities.

  12. Control the margin on top side of an element to 0.5rem using the mt-2 utilities.

  13. Control the text color of an element to 2xl using the text-2xl utilities.

  14. Control the text color of an element to gray-800 using the text-gray-800 utilities.

  15. Control the text color of an element to sm using the text-sm utilities.

  16. Control the text color of an element to gray-700 using the text-gray-700 utilities.

  17. Control the horizontal padding of an element to 0.5rem using the px-2 utilities.

  18. Control the margin on right side of an element to 0.25rem using the mr-1 utilities.

  19. Use flex to create a block-level flex container.

  20. Control the horizontal margin of an element to 1.5rem using the mx-6 utilities.

  21. Control the text color of an element to blue-500 using the text-blue-500 utilities.

  22. Control the text color of an element to xs using the text-xs utilities.

  23. Control the margin on left side of an element to -0.75rem using the -ml-3 utilities.

  24. Use w-6 to set an element to a fixed width(1.5rem).

  25. Use h-6 to set an element to a fixed height(1.5rem).

  26. Control the vertical margin of an element to 0.75rem using the my-3 utilities.

  27. Use w-12 to set an element to a fixed width(3rem).

  28. Use h-12 to set an element to a fixed height(3rem).

  29. Control the horizontal margin of an element to 1rem using the mx-4 utilities.

  30. Control the text color of an element to gray-900 using the text-gray-900 utilities.

  31. Control the text color of an element to gray-600 using the text-gray-600 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to create a Post/Article Card components, learn and follow along to implement your own components.