Published on

How To Build A Socail Post With Tailwind CSS From Scratch

Tags
Socail Post

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

Socail post

Why use Tailwind CSS to make a Socail Post ui component?

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

The preview of Socail Post ui component

Free download of the Socail Post's source code

The source code of Socail Post ui component

<!-- Create By Joker Banny -->
<div class="min-h-screen bg-gray-100 flex items-center overflow-hidden py-20">
  <div class="container mx-auto max-w-sm bg-white rounded-xl shadow-lg hover:scale-105 hover:shadow-2xl transform transition-all duration-500">
  <div class="flex items-center justify-between px-4">
    <div class="flex justify-between items-center py-4">
      <img class="w-12 rounded-full" src="https://d2qp0siotla746.cloudfront.net/img/use-cases/profile-picture/template_0.jpg" alt="Alex" />
      <div class="ml-3">
      <h1 class="text-xl font-bold text-gray-800 cursor-pointer">Stuar Manson</h1>
      <p class="text-sm text-gray-800 hover:underline cursor-pointer">#Publicado hace 2 horas</p>
      </div>
    </div>
    <div>
      <svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 cursor-pointer" fill="none" viewBox="0 0 24 24" stroke="currentColor">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z" />
      </svg>
    </div>
  </div>
  <img src="https://images.unsplash.com/photo-1527112862739-c3b9466d902e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=966&q=80" alt="">
  <div class="p-6">
    <h1 class="text-3xl font-bold text-gray-800 cursor-pointer ">Flores</h1>
    <h2 class="text-xl text-gray-800 font-semibold">by Stuar Manson</p>
    <p class="text-lg font font-thin">Lorem ipsum carrots, enhanced undergraduate developer, but they do occaecat time and vitality, Lorem ipsum carrots,</p>
  </div>
  </div>
</div>

How to make a Socail Post with Tailwind CSS?

Install tailwind css of verion 2.2.4

Use the script html tag to import the script of Tailwind CSS of the version 2.2.4

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to make a Socail Post component

  • min-h-screen
  • bg-gray-100
  • flex
  • overflow-hidden
  • py-20
  • mx-auto
  • max-w-sm
  • bg-white
  • px-4
  • py-4
  • w-12
  • ml-3
  • text-xl
  • text-gray-800
  • text-sm
  • h-7
  • w-7
  • p-6
  • text-3xl
  • text-lg

20 steps to make a Socail Post component with Tailwind CSS

  1. Set the minimum width/height of an element using the min-h-screen utilities.

  2. Control the background color of an element to gray-100 using the bg-gray-100 utilities.

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

  4. Use overflow-hidden to clip any content within an element that overflows the bounds of that element.

  5. Control the vertical padding of an element to 5rem using the py-20 utilities.

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

  7. Set the maximum width/height of an element using the max-w-sm utilities.

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

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

  10. Control the vertical padding of an element to 1rem using the py-4 utilities.

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

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

  13. Control the text color of an element to xl using the text-xl 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. Use h-7 to set an element to a fixed height(1.75rem).

  17. Use w-7 to set an element to a fixed width(1.75rem).

  18. Control the padding on all sides of an element to 1.5rem using the p-6 utilities.

  19. Control the text color of an element to 3xl using the text-3xl utilities.

  20. Control the text color of an element to lg using the text-lg utilities.

Conclusion

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