Published on

Ways To Make A Table UI With Tailwind CSS In 60 Minutes

Tags
Table UI

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

Use tailwind css and some custom css

Why use Tailwind CSS to make a Table UI ui component?

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

The preview of Table UI ui component

Free download of the Table UI's source code

The source code of Table UI ui component

<!-- This is an example component -->


<style>

    .table {
    border-spacing: 0 15px;
  }

  i {
    font-size: 1rem !important;
  }

  .table tr {
    border-radius: 20px;
  }

  tr td:nth-child(n + 6),
  tr th:nth-child(n + 6) {
    border-radius: 0 0.625rem 0.625rem 0;
  }

  tr td:nth-child(1),
  tr th:nth-child(1) {
    border-radius: 0.625rem 0 0 0.625rem;
  }

</style>

  
<!-- component -->
<link
  href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"
  rel="stylesheet"
/>
<div class="flex items-center justify-center min-h-screen bg-white">
  <div class="col-span-12">
    <div class="overflow-auto lg:overflow-visible">
      <div class="flex lg:justify-between border-b-2 border-fuchsia-900 pb-1">
        <h2 class="text-2xl text-gray-500 font-bold">All Users</h2>
        <div class="text-center flex-auto">
          <input
            type="text"
            name="name"
            placeholder="Search..."
            class="
              w-1/3
              py-2
              border-b-2 border-blue-600
              outline-none
              focus:border-yellow-400
            "
          />
        </div>

        <div>
          <a href="#">
            <button
              class="
                bg-blue-500
                hover:bg-blue-700
                text-white
                py-1
                px-3
                sm
                rounded-full
              "
            >
              All
            </button>
          </a>
          <a href="#">
            <button
              class="
                bg-blue-500
                hover:bg-blue-700
                text-white
                py-1
                px-3
                sm
                rounded-full
              "
            >
              Admin
            </button>
          </a>
          <a href="#">
            <button
              class="
                bg-blue-500
                hover:bg-blue-700
                text-white
                py-1
                px-3
                sm
                rounded-full
              "
            >
              User
            </button></a
          >
        </div>
      </div>
      <table class="table text-gray-400 border-separate space-y-6 text-sm">
        <thead class="bg-blue-500 text-white">
          <tr>
            <th class="p-3">Name</th>
            <th class="p-3 text-left">Mail</th>
            <th class="p-3 text-left">Phone</th>
            <th class="p-3 text-left">Role</th>

            <th class="p-3 text-left">Status</th>
            <th class="p-3 text-left">Action</th>
          </tr>
        </thead>
        <tbody>
      
          <tr class="bg-blue-200 lg:text-black">
            <td class="p-3 font-medium capitalize">Gazi Rahad</td>
            <td class="p-3">[email protected]</td>
            <td class="p-3">01648349009</td>
            <td class="p-3 uppercase">admin</td>

            <td class="p-3">
              <span class="bg-green-400 text-gray-50 rounded-md px-2"
                >ACTIVE</span
              >
            </td>
            <td class="p-3">
              <a href="#" class="text-gray-500 hover:text-gray-100 mr-2">
                <i class="material-icons-outlined text-base">visibility</i>
              </a>
              <a href="#" class="text-yellow-400 hover:text-gray-100 mx-2">
                <i class="material-icons-outlined text-base">edit</i>
              </a>
              <a
                href="#"
                class="text-red-400 hover:text-gray-100 ml-2"
              >
                <i class="material-icons-round text-base">delete_outline</i>
              </a>
            </td>
          </tr>
       <tr class="bg-blue-200 lg:text-black">
            <td class="p-3 font-medium capitalize">Arif Uddin</td>
            <td class="p-3">[email protected]</td>
            <td class="p-3">01648349009</td>
            <td class="p-3 uppercase">user</td>

            <td class="p-3">
              <span class="bg-green-400 text-gray-50 rounded-md px-2"
                >ACTIVE</span
              >
            </td>
            <td class="p-3">
              <a href="#" class="text-gray-500 hover:text-gray-100 mr-2">
                <i class="material-icons-outlined text-base">visibility</i>
              </a>
              <a href="#" class="text-yellow-400 hover:text-gray-100 mx-2">
                <i class="material-icons-outlined text-base">edit</i>
              </a>
              <a
                href="#"
                class="text-red-400 hover:text-gray-100 ml-2"
              >
                <i class="material-icons-round text-base">delete_outline</i>
              </a>
            </td>
          </tr>
             <tr class="bg-blue-200 lg:text-black">
            <td class="p-3 font-medium capitalize">Rubel Amin</td>
            <td class="p-3">[email protected]</td>
            <td class="p-3">01648349010</td>
            <td class="p-3 uppercase">admin</td>

            <td class="p-3">
              <span class="bg-green-400 text-gray-50 rounded-md px-2"
                >ACTIVE</span
              >
            </td>
            <td class="p-3">
              <a href="#" class="text-gray-500 hover:text-gray-100 mr-2">
                <i class="material-icons-outlined text-base">visibility</i>
              </a>
              <a href="#" class="text-yellow-400 hover:text-gray-100 mx-2">
                <i class="material-icons-outlined text-base">edit</i>
              </a>
              <a
                href="#"
                class="text-red-400 hover:text-gray-100 ml-2"
              >
                <i class="material-icons-round text-base">delete_outline</i>
              </a>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

How to make a Table UI 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 Table UI component

  • flex
  • min-h-screen
  • bg-white
  • overflow-auto
  • lg:overflow-visible
  • border-b-2
  • border-fuchsia-900
  • pb-1
  • text-2xl
  • text-gray-500
  • text-center
  • flex-auto
  • focus:border-yellow-400
  • table
  • text-gray-400
  • border-separate
  • text-sm
  • bg-blue-500
  • text-white
  • p-3
  • text-left
  • bg-blue-200
  • lg:text-black
  • bg-green-400
  • text-gray-50
  • px-2
  • hover:text-gray-100
  • mr-2
  • text-base
  • text-yellow-400
  • mx-2
  • text-red-400
  • ml-2

33 steps to make a Table UI component with Tailwind CSS

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

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

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

  4. Use overflow-auto to add scrollbars to an element in the event that its content overflows the bounds of that element. Unlike .overflow-scroll, which always shows scrollbars, this utility will only show them if scrolling is necessary.

  5. Use overflow-visible to prevent content within an element from being clipped at only large screen sizes. Note that any content that overflows the bounds of the element will then be visible.

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

  7. Control the border color of an element to fuchsia-900 using the border-fuchsia-900 utilities.

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

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

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

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

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

  13. Control the border color of an element to yellow-400 using the focus:border-yellow-400 utilities on focus.

  14. Use the table utilities to create elements that behave like their respective table elements.

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

  16. Control the border color of an element to separate using the border-separate utilities.

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

  18. Control the background color of an element to blue-500 using the bg-blue-500 utilities.

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

  20. Control the padding on all sides of an element to 0.75rem using the p-3 utilities.

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

  22. Control the background color of an element to blue-200 using the bg-blue-200 utilities.

  23. Control the text color of an element to black at only large screen sizes using the lg:text-black utilities.

  24. Control the background color of an element to green-400 using the bg-green-400 utilities.

  25. Control the text color of an element to gray-50 using the text-gray-50 utilities.

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

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

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

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

  30. Control the text color of an element to yellow-400 using the text-yellow-400 utilities.

  31. Control the horizontal margin of an element to 0.5rem using the mx-2 utilities.

  32. Control the text color of an element to red-400 using the text-red-400 utilities.

  33. Control the margin on left side of an element to 0.5rem using the ml-2 utilities.

Conclusion

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