Published on

Learn How To Make A Fitness Tracker With Tailwind CSS Like an Expert

Fitness Tracker

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 Fitness Tracker ui component

Fitness tracker app

Why use Tailwind CSS to build a Fitness Tracker ui component?

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

The preview of Fitness Tracker ui component

Free download of the Fitness Tracker's source code

The source code of Fitness Tracker ui component

<div class="w-full">

 <div class="bg-white px-8 py-4 flex flex-col rounded-xl">
    <header class="flex justify-between mb-16">
        <div>09:41</div>
        <div class="flex space-x-2">
        <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 8v8m-4-5v5m-4-2v2m-2 4h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
            </svg>
        </div>
        <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0" />
            </svg>
        </div>
        <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
            </svg>
        </div>
        </div>
    </header>

    <div class="flex justify-between mb-6">
        <div class="text-gray-500 font-semibold">Stay Healthy</div>
        <div class="flex space-x-2">
            <div>
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
                </svg>
            </div>
            <div>
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
                </svg>
            </div>
        </div>
    </div>

    <div class="text-3xl font-bold mb-3">Let's exercise today!</div>
    <div class="text-md font-semibold text-gray-500 mb-6">Take a look at your sport status below</div>

    <div class="flex justify-between mb-8">
        <div class="flex items-center space-x-3">
            <img src="https://bit.ly/3gaTsf4" class="h-12 w-12 object-cover rounded-full shadow-lg border-2 border-white"/>
            <div class="font-bold text-xl">Lv. 14</div>
        </div>
        <button class="border-2 border-black rounded-xl px-5 font-semibold bg-yellow-300">
            <span>+</span>
            <span>Challanges</span>
        </button>
    </div>

    <div class="border-2 border-black px-5 py-4 rounded-2xl bg-green-100 mb-8">
        <div class="font-semibold text-lg">Steps</div>
        <div class="font-semibold text-gray-600 mb-4">3245/6000</div>
        <div class="flex">
            <div class="w-2/5 h-6 bg-green-700 rounded-l-2xl"></div>
            <div class="w-3/5 h-6 bg-yellow-400 rounded-r-2xl"></div>
        </div>
    </div>
    
    <div class="border-2 border-black px-5 py-4 rounded-2xl bg-green-100 mb-8">
        <div class="flex space-x-2 items-center mb-5">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
            </svg>
            <div class="font-semibold text-lg">Active time</div>
        </div>
        <div class="flex justify-between">
            <div class="font-semibold text-gray-600">30/60 mins</div>
            <div class="font-thin text-gray-500">1712 Kcal | 1.23 KM</div>
        </div>
    </div>

    <div class="border-2 border-black px-5 py-4 rounded-2xl bg-green-100 mb-8">
        <div class="flex space-x-2 items-center mb-5">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
            </svg>
            <div class="font-semibold text-lg">Sleep time</div>
        </div>
        <div class="flex justify-between mb-3">
            <div class="font-semibold text-gray-600">6 h 30 mins</div>
        </div>
        <div class="flex">
            <div class="w-2/12 h-6 bg-green-400 rounded-l-2xl"></div>
            <div class="w-3/12 h-6 bg-yellow-700"></div>
            <div class="w-2/12 h-6 bg-purple-500"></div>
            <div class="w-2/12 h-6 bg-pink-300"></div>
            <div class="w-3/5 h-6 bg-yellow-400 rounded-r-2xl"></div>
        </div>
    </div>
 </div>
</div>

How to build a Fitness Tracker with Tailwind CSS?

Install tailwind css of verion 2.1.4

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

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

All the unility class needed to build a Fitness Tracker component

  • w-full
  • bg-white
  • px-8
  • py-4
  • flex
  • flex-col
  • mb-16
  • h-6
  • w-6
  • mb-6
  • text-gray-500
  • text-3xl
  • mb-3
  • text-md
  • mb-8
  • h-12
  • w-12
  • border-2
  • border-white
  • text-xl
  • border-black
  • px-5
  • bg-yellow-300
  • bg-green-100
  • text-lg
  • text-gray-600
  • mb-4
  • w-2/5
  • bg-green-700
  • w-3/5
  • bg-yellow-400
  • mb-5
  • w-2/12
  • bg-green-400
  • w-3/12
  • bg-yellow-700
  • bg-purple-500
  • bg-pink-300

38 steps to build a Fitness Tracker component with Tailwind CSS

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

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

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

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

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

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

  7. Control the margin on bottom side of an element to 4rem using the mb-16 utilities.

  8. Use h-6 to set an element to a fixed height(1.5rem).

  9. Use w-6 to set an element to a fixed width(1.5rem).

  10. Control the margin on bottom side of an element to 1.5rem using the mb-6 utilities.

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

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

  13. Control the margin on bottom side of an element to 0.75rem using the mb-3 utilities.

  14. Control the text color of an element to md using the text-md utilities.

  15. Control the margin on bottom side of an element to 2rem using the mb-8 utilities.

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

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

  18. Control the border color of an element to 0.5rem using the border-2 utilities.

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

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

  21. Control the border color of an element to black using the border-black utilities.

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

  23. Control the background color of an element to yellow-300 using the bg-yellow-300 utilities.

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

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

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

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

  28. Use w-2/5 to set an element to a fixed width(2/5).

  29. Control the background color of an element to green-700 using the bg-green-700 utilities.

  30. Use w-3/5 to set an element to a fixed width(3/5).

  31. Control the background color of an element to yellow-400 using the bg-yellow-400 utilities.

  32. Control the margin on bottom side of an element to 1.25rem using the mb-5 utilities.

  33. Use w-2/12 to set an element to a fixed width(2/12).

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

  35. Use w-3/12 to set an element to a fixed width(3/12).

  36. Control the background color of an element to yellow-700 using the bg-yellow-700 utilities.

  37. Control the background color of an element to purple-500 using the bg-purple-500 utilities.

  38. Control the background color of an element to pink-300 using the bg-pink-300 utilities.

Conclusion

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