Published on

Build A Table Responsive with Filters With Tailwind CSS Like A Pro With The Help Of These 6 Tips

Table Responsive with Filters

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 Responsive with Filters ui component

Table with filters and pagination

Why use Tailwind CSS to create a Table Responsive with Filters ui component?

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

The preview of Table Responsive with Filters ui component

Free download of the Table Responsive with Filters's source code

The source code of Table Responsive with Filters ui component

<body class="antialiased font-sans bg-gray-200">
    <div class="container mx-auto px-4 sm:px-8">
        <div class="py-8">
            <div>
                <h2 class="text-2xl font-semibold leading-tight">Users</h2>
            </div>
            <div class="my-2 flex sm:flex-row flex-col">
                <div class="flex flex-row mb-1 sm:mb-0">
                    <div class="relative">
                        <select
                            class="appearance-none h-full rounded-l border block appearance-none w-full bg-white border-gray-400 text-gray-700 py-2 px-4 pr-8 leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
                            <option>5</option>
                            <option>10</option>
                            <option>20</option>
                        </select>
                        <div
                            class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
                            </svg>
                        </div>
                    </div>
                    <div class="relative">
                        <select
                            class="appearance-none h-full rounded-r border-t sm:rounded-r-none sm:border-r-0 border-r border-b block appearance-none w-full bg-white border-gray-400 text-gray-700 py-2 px-4 pr-8 leading-tight focus:outline-none focus:border-l focus:border-r focus:bg-white focus:border-gray-500">
                            <option>All</option>
                            <option>Active</option>
                            <option>Inactive</option>
                        </select>
                        <div
                            class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
                            </svg>
                        </div>
                    </div>
                </div>
                <div class="block relative">
                    <span class="h-full absolute inset-y-0 left-0 flex items-center pl-2">
                        <svg viewBox="0 0 24 24" class="h-4 w-4 fill-current text-gray-500">
                            <path
                                d="M10 4a6 6 0 100 12 6 6 0 000-12zm-8 6a8 8 0 1114.32 4.906l5.387 5.387a1 1 0 01-1.414 1.414l-5.387-5.387A8 8 0 012 10z">
                            </path>
                        </svg>
                    </span>
                    <input placeholder="Search"
                        class="appearance-none rounded-r rounded-l sm:rounded-l-none border border-gray-400 border-b block pl-8 pr-6 py-2 w-full bg-white text-sm placeholder-gray-400 text-gray-700 focus:bg-white focus:placeholder-gray-600 focus:text-gray-700 focus:outline-none" />
                </div>
            </div>
            <div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
                <div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
                    <table class="min-w-full leading-normal">
                        <thead>
                            <tr>
                                <th
                                    class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
                                    User
                                </th>
                                <th
                                    class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
                                    Rol
                                </th>
                                <th
                                    class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
                                    Created at
                                </th>
                                <th
                                    class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
                                    Status
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 w-10 h-10">
                                            <img class="w-full h-full rounded-full"
                                                src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.2&w=160&h=160&q=80"
                                                alt="" />
                                        </div>
                                        <div class="ml-3">
                                            <p class="text-gray-900 whitespace-no-wrap">
                                                Vera Carpenter
                                            </p>
                                        </div>
                                    </div>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">Admin</p>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">
                                        Jan 21, 2020
                                    </p>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <span
                                        class="relative inline-block px-3 py-1 font-semibold text-green-900 leading-tight">
                                        <span aria-hidden
                                            class="absolute inset-0 bg-green-200 opacity-50 rounded-full"></span>
                                        <span class="relative">Activo</span>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 w-10 h-10">
                                            <img class="w-full h-full rounded-full"
                                                src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.2&w=160&h=160&q=80"
                                                alt="" />
                                        </div>
                                        <div class="ml-3">
                                            <p class="text-gray-900 whitespace-no-wrap">
                                                Blake Bowman
                                            </p>
                                        </div>
                                    </div>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">Editor</p>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">
                                        Jan 01, 2020
                                    </p>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <span
                                        class="relative inline-block px-3 py-1 font-semibold text-green-900 leading-tight">
                                        <span aria-hidden
                                            class="absolute inset-0 bg-green-200 opacity-50 rounded-full"></span>
                                        <span class="relative">Activo</span>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 w-10 h-10">
                                            <img class="w-full h-full rounded-full"
                                                src="https://images.unsplash.com/photo-1540845511934-7721dd7adec3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.2&w=160&h=160&q=80"
                                                alt="" />
                                        </div>
                                        <div class="ml-3">
                                            <p class="text-gray-900 whitespace-no-wrap">
                                                Dana Moore
                                            </p>
                                        </div>
                                    </div>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">Editor</p>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">
                                        Jan 10, 2020
                                    </p>
                                </td>
                                <td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
                                    <span
                                        class="relative inline-block px-3 py-1 font-semibold text-orange-900 leading-tight">
                                        <span aria-hidden
                                            class="absolute inset-0 bg-orange-200 opacity-50 rounded-full"></span>
                                        <span class="relative">Suspended</span>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td class="px-5 py-5 bg-white text-sm">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 w-10 h-10">
                                            <img class="w-full h-full rounded-full"
                                                src="https://images.unsplash.com/photo-1522609925277-66fea332c575?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.2&h=160&w=160&q=80"
                                                alt="" />
                                        </div>
                                        <div class="ml-3">
                                            <p class="text-gray-900 whitespace-no-wrap">
                                                Alonzo Cox
                                            </p>
                                        </div>
                                    </div>
                                </td>
                                <td class="px-5 py-5 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">Admin</p>
                                </td>
                                <td class="px-5 py-5 bg-white text-sm">
                                    <p class="text-gray-900 whitespace-no-wrap">Jan 18, 2020</p>
                                </td>
                                <td class="px-5 py-5 bg-white text-sm">
                                    <span
                                        class="relative inline-block px-3 py-1 font-semibold text-red-900 leading-tight">
                                        <span aria-hidden
                                            class="absolute inset-0 bg-red-200 opacity-50 rounded-full"></span>
                                        <span class="relative">Inactive</span>
                                    </span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div
                        class="px-5 py-5 bg-white border-t flex flex-col xs:flex-row items-center xs:justify-between          ">
                        <span class="text-xs xs:text-sm text-gray-900">
                            Showing 1 to 4 of 50 Entries
                        </span>
                        <div class="inline-flex mt-2 xs:mt-0">
                            <button
                                class="text-sm bg-gray-300 hover:bg-gray-400 text-gray-800 font-semibold py-2 px-4 rounded-l">
                                Prev
                            </button>
                            <button
                                class="text-sm bg-gray-300 hover:bg-gray-400 text-gray-800 font-semibold py-2 px-4 rounded-r">
                                Next
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

How to create a Table Responsive with Filters with Tailwind CSS?

Install tailwind css of verion 1.0.4

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

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

All the unility class needed to create a Table Responsive with Filters component

  • bg-gray-200
  • mx-auto
  • px-4
  • sm:px-8
  • py-8
  • text-2xl
  • my-2
  • flex
  • sm:flex-row
  • flex-col
  • flex-row
  • mb-1
  • sm:mb-0
  • relative
  • h-full
  • block
  • w-full
  • bg-white
  • border-gray-400
  • text-gray-700
  • py-2
  • pr-8
  • focus:bg-white
  • focus:border-gray-500
  • absolute
  • right-0
  • px-2
  • h-4
  • w-4
  • border-t
  • sm:border-r-0
  • border-r
  • border-b
  • focus:border-l
  • focus:border-r
  • left-0
  • pl-2
  • text-gray-500
  • pl-8
  • pr-6
  • text-sm
  • focus:text-gray-700
  • -mx-4
  • sm:-mx-8
  • py-4
  • overflow-x-auto
  • inline-block
  • min-w-full
  • overflow-hidden
  • px-5
  • py-3
  • border-b-2
  • border-gray-200
  • bg-gray-100
  • text-left
  • text-xs
  • text-gray-600
  • py-5
  • flex-shrink-0
  • w-10
  • h-10
  • ml-3
  • text-gray-900
  • px-3
  • py-1
  • text-green-900
  • bg-green-200
  • text-orange-900
  • bg-orange-200
  • text-red-900
  • bg-red-200
  • xs:flex-row
  • xs:text-sm
  • inline-flex
  • mt-2
  • xs:mt-0
  • bg-gray-300
  • hover:bg-gray-400
  • text-gray-800

79 steps to create a Table Responsive with Filters component with Tailwind CSS

  1. Control the background color of an element to gray-200 using the bg-gray-200 utilities.

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

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

  4. Control the horizontal padding of an element to 2rem at only small screen sizes using the sm:px-8 utilities.

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

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

  7. Control the vertical margin of an element to 0.5rem using the my-2 utilities.

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

  9. Use flex to create a block-level flex container at only small screen sizes.

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

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

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

  13. Control the margin on bottom side of an element to 0rem at only small screen sizes using the sm:mb-0 utilities.

  14. Use relative to position an element according to the normal flow of the document.

  15. Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

  16. Use inline utilities to put the element on its own line and fill its parent.

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

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

  19. Control the border color of an element to gray-400 using the border-gray-400 utilities.

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

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

  22. Control the padding on right side of an element to 2rem using the pr-8 utilities.

  23. Control the background color of an element to white using the focus:bg-white utilities on focus.

  24. Control the border color of an element to gray-500 using the focus:border-gray-500 utilities on focus.

  25. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  26. Use the right-0 utilities to set the right position of a positioned element to 0rem.

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

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

  29. Use w-4 to set an element to a fixed width(1rem).

  30. Control the border color of an element to t using the border-t utilities.

  31. Control the border color of an element to r-0 using the sm:border-r-0 utilities at only small screen sizes.

  32. Control the border color of an element to r using the border-r utilities.

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

  34. Control the border color of an element to l using the focus:border-l utilities on focus.

  35. Control the border color of an element to r using the focus:border-r utilities on focus.

  36. Use the left-0 utilities to set the left position of a positioned element to 0rem.

  37. Adjust the left padding of an element to 0.5rem using the pl-2 utilities class

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

  39. Adjust the left padding of an element to 2rem using the pl-8 utilities class

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

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

  42. Control the text color of an element to gray-700 on focus using the focus:text-gray-700 utilities.

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

  44. Control the horizontal margin of an element to -2rem at only small screen sizes using the sm:-mx-8 utilities.

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

  46. Use overflow-x-auto to allow horizontal scrolling if needed.

  47. Use inline-block utilities to wrap the element to prevent the text inside from extending beyond its parent.

  48. Set the minimum width/height of an element using the min-w-full utilities.

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

  50. Control the horizontal padding of an element to 1.25rem using the px-5 utilities.

  51. Control the vertical padding of an element to 0.75rem using the py-3 utilities.

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

  53. Control the border color of an element to gray-200 using the border-gray-200 utilities.

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

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

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

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

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

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

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

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

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

  63. Control the text color of an element to gray-900 using the text-gray-900 utilities.

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

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

  66. Control the text color of an element to green-900 using the text-green-900 utilities.

  67. Control the background color of an element to green-200 using the bg-green-200 utilities.

  68. Control the text color of an element to orange-900 using the text-orange-900 utilities.

  69. Control the background color of an element to orange-200 using the bg-orange-200 utilities.

  70. Control the text color of an element to red-900 using the text-red-900 utilities.

  71. Control the background color of an element to red-200 using the bg-red-200 utilities.

  72. Use flex to create a block-level flex containerundefined.

  73. Control the text color of an element to smundefined using the xs:text-sm utilities.

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

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

  76. Control the margin on top side of an element to 0remundefined using the xs:mt-0 utilities.

  77. Control the background color of an element to gray-300 using the bg-gray-300 utilities.

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

  79. Control the text color of an element to gray-800 using the text-gray-800 utilities.

Conclusion

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