Published on

Advanced Guide: Make A WhatsApp With Tailwind CSS

Tags
WhatsApp

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

Wa

Why use Tailwind CSS to create a WhatsApp ui component?

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

The preview of WhatsApp ui component

Free download of the WhatsApp's source code

The source code of WhatsApp ui component

<div class="flex flex-col min-h-screen max-w-sm mx-auto">
  <header class="flex flex-wrap pt-3 text-white mb-1" style="background-color:#128C7E">
    <div class="flex justify-between text-xl w-full font-medium pl-4">
      WhatsApp
      <div class="flex items-center">
        <svg
          class="h-4 mr-6 text-base"
          role="img"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 512 512"
        >
          <path
            fill="currentColor"
            d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
          ></path></svg
        ><svg
          class="h-4 mr-4 text-base"
          style=""
          role="img"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 192 512"
        >
          <path
            fill="currentColor"
            d="M96 184c39.8 0 72 32.2 72 72s-32.2 72-72 72-72-32.2-72-72 32.2-72 72-72zM24 80c0 39.8 32.2 72 72 72s72-32.2 72-72S135.8 8 96 8 24 40.2 24 80zm0 352c0 39.8 32.2 72 72 72s72-32.2 72-72-32.2-72-72-72-72 32.2-72 72z"
          ></path>
        </svg>
      </div>
    </div>
    <div class="flex w-full items-center mt-4">
      <div class="pl-3 w-full">
        <svg
          class="h-4"
          role="img"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 512 512"
        >
          <path
            fill="currentColor"
            d="M512 144v288c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48h88l12.3-32.9c7-18.7 24.9-31.1 44.9-31.1h125.5c20 0 37.9 12.4 44.9 31.1L376 96h88c26.5 0 48 21.5 48 48zM376 288c0-66.2-53.8-120-120-120s-120 53.8-120 120 53.8 120 120 120 120-53.8 120-120zm-32 0c0 48.5-39.5 88-88 88s-88-39.5-88-88 39.5-88 88-88 88 39.5 88 88z"
          ></path>
        </svg>
      </div>
      <button
        class="opacity-100 border-b-2 border-white tracking-wide text-sm uppercase font-medium text-center py-2 px-8 focus:outline-none"
      >
        chats
      </button>
      <button
        class="opacity-50 tracking-wide text-sm uppercase font-medium text-center py-2 px-8 focus:outline-none"
      >
        status
      </button>
      <button
        class="opacity-50 tracking-wide text-sm uppercase font-medium text-center py-2 px-8 focus:outline-none"
      >
        calls
      </button>
    </div>
  </header>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/hafeeskhan/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Marques
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/billyroshan/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Glenda
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/kudretkeskin/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Tyler
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/d33pthought/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Amalia
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/rweve/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Bruce
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/cherif_b/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Jovan
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/mekal/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Beverly
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/ky/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Providenci
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/vimarethomas/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Julia
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="px-3 pt-1 mt-1 flex">
    <img
      src="https://s3.amazonaws.com/uifaces/faces/twitter/belyaev_rs/128.jpg"
      class=" w-12 h-12 rounded-full"
      alt="dp"
    />
    <div class="flex flex-wrap ml-4 pb-4 w-full">
      <div class="inline-flex justify-between w-full font-bold">
        Ivy
        <span
          class="inline-flex items-center font-normal text-gray-400 text-xs"
        >
          yesterday
        </span>
      </div>
      <div class="inline-flex w-full text-sm text-gray-500">lorem ipsum</div>
    </div>
  </div>
  <div class="text-center text-xs text-gray-600 mt-4">Archived</div>
</div>

How to create a WhatsApp with Tailwind CSS?

Install tailwind css of verion 1.9.6

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

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

All the unility class needed to create a WhatsApp component

  • flex
  • flex-col
  • min-h-screen
  • max-w-sm
  • mx-auto
  • flex-wrap
  • pt-3
  • text-white
  • mb-1
  • text-xl
  • w-full
  • pl-4
  • h-4
  • mr-6
  • text-base
  • mr-4
  • mt-4
  • pl-3
  • border-b-2
  • border-white
  • text-sm
  • text-center
  • py-2
  • px-8
  • px-3
  • pt-1
  • mt-1
  • w-12
  • h-12
  • ml-4
  • pb-4
  • inline-flex
  • text-gray-400
  • text-xs
  • text-gray-500
  • text-gray-600

36 steps to create a WhatsApp component with Tailwind CSS

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

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

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

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

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

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

  7. Control the padding on top side of an element to 0.75rem using the pt-3 utilities.

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

  9. Control the margin on bottom side of an element to 0.25rem using the mb-1 utilities.

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

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

  12. Adjust the left padding of an element to 1rem using the pl-4 utilities class

  13. Use h-4 to set an element to a fixed height(1rem).

  14. Control the margin on right side of an element to 1.5rem using the mr-6 utilities.

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

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

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

  18. Adjust the left padding of an element to 0.75rem using the pl-3 utilities class

  19. Control the border color of an element to b-2 using the border-b-2 utilities.

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

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

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

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

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

  25. Control the horizontal padding of an element to 0.75rem using the px-3 utilities.

  26. Control the padding on top side of an element to 0.25rem using the pt-1 utilities.

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

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

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

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

  31. Control the padding on bottom side of an element to 1rem using the pb-4 utilities.

  32. Use inline-flex to create an inline flex container that flows with text.

  33. Control the text color of an element to gray-400 using the text-gray-400 utilities.

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

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

  36. 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 WhatsApp components, learn and follow along to implement your own components.