Published on

Beginners Guide: Build A Post Article With Tailwind CSS

Tags
Post Article

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 ui component

A post article for tailwind ccss

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

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

The preview of Post Article ui component

Free download of the Post Article's source code

The source code of Post Article ui component

<div class="max-w-4xl px-10 my-4 py-6 bg-white rounded-lg shadow-md">
        <div class="flex justify-between items-center">
            <span class="font-light text-gray-600">mar 10, 2019</span>
            <a class="px-2 py-1 bg-gray-600 text-gray-100 font-bold rounded hover:bg-gray-500" href="#">Design</a>
        </div>
        <div class="mt-2">
            <a class="text-2xl text-gray-700 font-bold hover:text-gray-600" href="#">Accessibility tools for designers and developers</a>
            <p class="mt-2 text-gray-600">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Tempora expedita dicta totam aspernatur doloremque. Excepturi iste iusto eos enim reprehenderit nisi, accusamus delectus nihil quis facere in modi ratione libero!</p>
        </div>
        <div class="flex justify-between items-center mt-4">
            <a class="text-blue-600 hover:underline" href="#">Read more</a>
            <div>
                <a class="flex items-center" href="#">
                    <img class="mx-4 w-10 h-10 object-cover rounded-full hidden sm:block" src="https://images.unsplash.com/photo-1502980426475-b83966705988?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=373&q=80" alt="avatar">
                    <h1 class="text-gray-700 font-bold">Khatab wedaa</h1>
                </a>
            </div>
        </div>
    </div>

How to create a Post Article with Tailwind CSS?

Install tailwind css of verion 1.2.0

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

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

All the unility class needed to create a Post Article component

  • max-w-4xl
  • px-10
  • my-4
  • py-6
  • bg-white
  • flex
  • text-gray-600
  • px-2
  • py-1
  • bg-gray-600
  • text-gray-100
  • hover:bg-gray-500
  • mt-2
  • text-2xl
  • text-gray-700
  • hover:text-gray-600
  • mt-4
  • text-blue-600
  • mx-4
  • w-10
  • h-10
  • hidden
  • sm:block

23 steps to create a Post Article component with Tailwind CSS

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

  2. Control the horizontal padding of an element to 2.5rem using the px-10 utilities.

  3. Control the vertical margin of an element to 1rem using the my-4 utilities.

  4. Control the vertical padding of an element to 1.5rem using the py-6 utilities.

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

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

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

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

  9. Control the vertical padding of an element to 0.25rem using the py-1 utilities.

  10. Control the background color of an element to gray-600 using the bg-gray-600 utilities.

  11. Control the text color of an element to gray-100 using the text-gray-100 utilities.

  12. Control the background color of an element to gray-500 using the hover:bg-gray-500 utilities on hover.

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

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

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

  16. Control the text color of an element to gray-600 on hover using the hover:text-gray-600 utilities.

  17. Control the margin on top side of an element to 1rem using the mt-4 utilities.

  18. Control the text color of an element to blue-600 using the text-blue-600 utilities.

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

  20. Use w-10 to set an element to a fixed width(2.5rem).

  21. Use h-10 to set an element to a fixed height(2.5rem).

  22. Use hidden to set an element to display: none and remove it from the page layout.

  23. Use inline utilities to put the element on its own line and fill its parent at only small screen sizes.

Conclusion

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