Published on

Ultimate Guide: Make A Facebook Comment With Tailwind CSS

Tags
Facebook Comment

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

Facebook's new ui comment with dark mode

Why use Tailwind CSS to create a Facebook Comment ui component?

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

The preview of Facebook Comment ui component

Free download of the Facebook Comment's source code

The source code of Facebook Comment ui component

<div class="flex items-center justify-center w-screen h-screen bg-white dark:bg-gray-800">
<div class="bg-white dark:bg-gray-800 text-black dark:text-gray-200 p-4 antialiased flex max-w-lg">
  <img class="rounded-full h-8 w-8 mr-2 mt-1 " src="https://picsum.photos/id/1027/200/200"/>
  <div>
    <div class="bg-gray-100 dark:bg-gray-700 rounded-3xl px-4 pt-2 pb-2.5">
      <div class="font-semibold text-sm leading-relaxed">Jon Doe</div>
      <div class="text-normal leading-snug md:leading-normal"
      >Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
    </div>
    <div class="text-sm ml-4 mt-0.5 text-gray-500 dark:text-gray-400">14 w</div>
    <div class="bg-white dark:bg-gray-700 border border-white dark:border-gray-700 rounded-full float-right -mt-8 mr-0.5 flex shadow items-center ">
      <svg class="p-0.5 h-5 w-5 rounded-full z-20 bg-white dark:bg-gray-700" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 16 16'><defs><linearGradient id='a1' x1='50%' x2='50%' y1='0%' y2='100%'><stop offset='0%' stop-color='#18AFFF'/><stop offset='100%' stop-color='#0062DF'/></linearGradient><filter id='c1' width='118.8%' height='118.8%' x='-9.4%' y='-9.4%' filterUnits='objectBoundingBox'><feGaussianBlur in='SourceAlpha' result='shadowBlurInner1' stdDeviation='1'/><feOffset dy='-1' in='shadowBlurInner1' result='shadowOffsetInner1'/><feComposite in='shadowOffsetInner1' in2='SourceAlpha' k2='-1' k3='1' operator='arithmetic' result='shadowInnerInner1'/><feColorMatrix in='shadowInnerInner1' values='0 0 0 0 0 0 0 0 0 0.299356041 0 0 0 0 0.681187726 0 0 0 0.3495684 0'/></filter><path id='b1' d='M8 0a8 8 0 00-8 8 8 8 0 1016 0 8 8 0 00-8-8z'/></defs><g fill='none'><use fill='url(#a1)' xlink:href='#b1'/><use fill='black' filter='url(#c1)' xlink:href='#b1'/><path fill='white' d='M12.162 7.338c.176.123.338.245.338.674 0 .43-.229.604-.474.725a.73.73 0 01.089.546c-.077.344-.392.611-.672.69.121.194.159.385.015.62-.185.295-.346.407-1.058.407H7.5c-.988 0-1.5-.546-1.5-1V7.665c0-1.23 1.467-2.275 1.467-3.13L7.361 3.47c-.005-.065.008-.224.058-.27.08-.079.301-.2.635-.2.218 0 .363.041.534.123.581.277.732.978.732 1.542 0 .271-.414 1.083-.47 1.364 0 0 .867-.192 1.879-.199 1.061-.006 1.749.19 1.749.842 0 .261-.219.523-.316.666zM3.6 7h.8a.6.6 0 01.6.6v3.8a.6.6 0 01-.6.6h-.8a.6.6 0 01-.6-.6V7.6a.6.6 0 01.6-.6z'/></g></svg>
      <svg class="p-0.5 h-5 w-5 rounded-full -ml-1.5 bg-white dark:bg-gray-700" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 16 16'><defs><linearGradient id='a2' x1='50%' x2='50%' y1='0%' y2='100%'><stop offset='0%' stop-color='#FF6680'/><stop offset='100%' stop-color='#E61739'/></linearGradient><filter id='c2' width='118.8%' height='118.8%' x='-9.4%' y='-9.4%' filterUnits='objectBoundingBox'><feGaussianBlur in='SourceAlpha' result='shadowBlurInner1' stdDeviation='1'/><feOffset dy='-1' in='shadowBlurInner1' result='shadowOffsetInner1'/><feComposite in='shadowOffsetInner1' in2='SourceAlpha' k2='-1' k3='1' operator='arithmetic' result='shadowInnerInner1'/><feColorMatrix in='shadowInnerInner1' values='0 0 0 0 0.710144928 0 0 0 0 0 0 0 0 0 0.117780134 0 0 0 0.349786932 0'/></filter><path id='b2' d='M8 0a8 8 0 100 16A8 8 0 008 0z'/></defs><g fill='none'><use fill='url(#a2)' xlink:href='#b2'/><use fill='black' filter='url(#c2)' xlink:href='#b2'/><path fill='white' d='M10.473 4C8.275 4 8 5.824 8 5.824S7.726 4 5.528 4c-2.114 0-2.73 2.222-2.472 3.41C3.736 10.55 8 12.75 8 12.75s4.265-2.2 4.945-5.34c.257-1.188-.36-3.41-2.472-3.41'/></g></svg>
      <span class="text-sm ml-1 pr-1.5 text-gray-500 dark:text-gray-300">3</span>
    </div>
  </div>
</div>
</div>

How to create a Facebook Comment with Tailwind CSS?

Install tailwind css of verion 2.0.3

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

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

All the unility class needed to create a Facebook Comment component

  • flex
  • w-screen
  • h-screen
  • bg-white
  • dark:bg-gray-800
  • text-black
  • dark:text-gray-200
  • p-4
  • max-w-lg
  • h-8
  • w-8
  • mr-2
  • mt-1
  • bg-gray-100
  • dark:bg-gray-700
  • px-4
  • pt-2
  • pb-2.5
  • text-sm
  • text-normal
  • ml-4
  • mt-0.5
  • text-gray-500
  • dark:text-gray-400
  • border-white
  • dark:border-gray-700
  • float-right
  • -mt-8
  • mr-0.5
  • p-0.5
  • h-5
  • w-5
  • z-20
  • -ml-1.5
  • ml-1
  • pr-1.5
  • dark:text-gray-300

37 steps to create a Facebook Comment component with Tailwind CSS

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

  2. Use w-screen to make an element span the entire width of the viewport.

  3. Use h-screen to make an element span the entire height of the viewport.

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

  5. Control the background color of an element to gray-800 using the dark:bg-gray-800 utilities in dark theme.

  6. Control the text color of an element to black using the text-black utilities.

  7. Control the text color of an element to gray-200 in dark theme using the dark:text-gray-200 utilities.

  8. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  9. Set the maximum width/height of an element using the max-w-lg utilities.

  10. Use h-8 to set an element to a fixed height(2rem).

  11. Use w-8 to set an element to a fixed width(2rem).

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

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

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

  15. Control the background color of an element to gray-700 using the dark:bg-gray-700 utilities in dark theme.

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

  17. Control the padding on top side of an element to 0.5rem using the pt-2 utilities.

  18. Control the padding on bottom side of an element to 2.5 using the pb-2.5 utilities.

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

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

  21. Control the margin on left side of an element to 1rem using the ml-4 utilities.

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

  23. Control the text color of an element to gray-500 using the text-gray-500 utilities.

  24. Control the text color of an element to gray-400 in dark theme using the dark:text-gray-400 utilities.

  25. Control the border color of an element to white using the border-white utilities.

  26. Control the border color of an element to gray-700 using the dark:border-gray-700 utilities in dark theme.

  27. Use float-right to float an element to the right of its container.

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

  29. Control the margin on right side of an element to 0.5 using the mr-0.5 utilities.

  30. Control the padding on all sides of an element to 0.5 using the p-0.5 utilities.

  31. Use h-5 to set an element to a fixed height(1.25rem).

  32. Use w-5 to set an element to a fixed width(1.25rem).

  33. Control the stack order (or three-dimensional positioning) of an element to 20 in Tailwind, regardless of order it has been displayed, using the z-20 utilities.

  34. Control the margin on left side of an element to 1.5 using the -ml-1.5 utilities.

  35. Control the margin on left side of an element to 0.25rem using the ml-1 utilities.

  36. Control the padding on right side of an element to 1.5 using the pr-1.5 utilities.

  37. Control the text color of an element to gray-300 in dark theme using the dark:text-gray-300 utilities.

Conclusion

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