Published on

How To Create A Free Tailwind CSS Hero Component With Tailwind CSS From Scratch

Tags
Free Tailwind CSS Hero Component

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 Free Tailwind CSS Hero Component ui component

Tailwind hero component is the front and center of a web page. find more free and premium tailwind css components at www.tailwinduikit.com

Why use Tailwind CSS to create a Free Tailwind CSS Hero Component ui component?

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

The preview of Free Tailwind CSS Hero Component ui component

Free download of the Free Tailwind CSS Hero Component's source code

The source code of Free Tailwind CSS Hero Component ui component

<dh-component>
  <!--   more free components available at www.TailwindUIKit.com -->
  <nav class="w-full border-b">
    <div class="py-5 md:py-0 container mx-auto px-6 flex items-center justify-between">
      <div aria-label="Home. logo" role="img">
        <img class="w-12 md:w-auto" src="https://tuk-cdn.s3.amazonaws.com/can-uploader/centre_aligned_simple-Svg1.svg" alt="logo" />
      </div>
      <div>
        <button onclick="toggleMenu(true)" class="sm:block md:hidden text-gray-500 hover:text-gray-700 focus:text-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500">
          <svg aria-haspopup="true" aria-label="open Main Menu" xmlns="http://www.w3.org/2000/svg" class="md:hidden icon icon-tabler icon-tabler-menu" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round">
            <path stroke="none" d="M0 0h24v24H0z"></path>
            <line x1="4" y1="8" x2="20" y2="8"></line>
            <line x1="4" y1="16" x2="20" y2="16"></line>
          </svg>
        </button>
        <div id="menu" class="md:block lg:block hidden">
          <button onclick="toggleMenu(false)" class="block md:hidden lg:hidden text-gray-500 hover:text-gray-700 focus:text-gray-700 fixed focus:outline-none focus:ring-2 focus:ring-gray-500 z-30 top-0 mt-6">
            <svg aria-label="close main menu" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
              <path stroke="none" d="M0 0h24v24H0z" />
              <line x1="18" y1="6" x2="6" y2="18" />
              <line x1="6" y1="6" x2="18" y2="18" />
            </svg>
          </button>
          <ul class="flex text-3xl md:text-base items-center py-10 md:flex flex-col md:flex-row justify-center fixed md:relative top-0 bottom-0 left-0 right-0 bg-white md:bg-transparent z-20">
            <li class="text-gray-700 hover:text-gray-900 cursor-pointer text-base lg:text-lg pt-10 md:pt-0">
              <a href="javascript: void(0)">Feature</a>
            </li>
            <li class="text-gray-700 hover:text-gray-900 cursor-pointer text-base lg:text-lg pt-10 md:pt-0 md:ml-5 lg:ml-10">
              <a href="javascript: void(0)">Marketplace</a>
            </li>
            <li class="text-gray-700 hover:text-gray-900 cursor-pointer text-base lg:text-lg pt-10 md:pt-0 md:ml-5 lg:ml-10">
              <a href="javascript: void(0)">Company</a>
            </li>
            <li class="text-gray-700 hover:text-gray-900 cursor-pointer text-base lg:text-lg pt-10 md:pt-0 md:ml-5 lg:ml-10">
              <a href="javascript: void(0)">Features</a>
            </li>
            <li class="text-gray-700 hover:text-gray-900 cursor-pointer text-base lg:text-lg pt-10 md:pt-0 md:ml-5 lg:ml-10">
              <a href="javascript: void(0)">Contact</a>
            </li>
          </ul>
        </div>
      </div>
      <button class="focus:outline-none lg:text-lg lg:font-bold focus:ring-2 focus:ring-offset-2 focus:ring-indigo-700 hidden md:block bg-transparent transition duration-150 ease-in-out hover:bg-gray-200 rounded border border-indigo-700 text-indigo-700 px-4 sm:px-8 py-1 sm:py-3 text-sm">Sign In</button>
    </div>
  </nav>
  <div class="bg-gray-100">
    <div class="container mx-auto flex flex-col items-center py-12 sm:py-24">
      <div class="w-11/12 sm:w-2/3 lg:flex justify-center items-center flex-col  mb-5 sm:mb-10">
        <h1 class="text-2xl sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl text-center text-gray-800 font-black leading-7 md:leading-10">
          The Freedom to Create the
          <span class="text-indigo-700">Websites</span>
          You Want
        </h1>
        <p class="mt-5 sm:mt-10 lg:w-10/12 text-gray-400 font-normal text-center text-sm sm:text-lg">A professonal website drives sales. Create a beautiful website to impress and engage new customers and establish your business online </p>
      </div>
      <div class="flex justify-center items-center">
        <button class="focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-700 bg-indigo-700 transition duration-150 ease-in-out hover:bg-indigo-600 lg:text-xl lg:font-bold  rounded text-white px-4 sm:px-10 border border-indigo-700 py-2 sm:py-4 text-sm">Get Started</button>
        <button class="ml-4 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-700 bg-transparent transition duration-150 ease-in-out hover:border-indigo-600 lg:text-xl lg:font-bold  hover:text-indigo-600 rounded border border-indigo-700 text-indigo-700 px-4 sm:px-10 py-2 sm:py-4 text-sm">Live Demo</button>
      </div>
    </div>
  </div>
</dh-component>

How to create a Free Tailwind CSS Hero Component with Tailwind CSS?

Install tailwind css of verion 2.2.19

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

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

All the unility class needed to create a Free Tailwind CSS Hero Component component

  • w-full
  • border-b
  • py-5
  • md:py-0
  • mx-auto
  • px-6
  • flex
  • w-12
  • md:w-auto
  • sm:block
  • md:hidden
  • text-gray-500
  • hover:text-gray-700
  • focus:text-gray-700
  • md:block
  • lg:block
  • hidden
  • block
  • lg:hidden
  • fixed
  • z-30
  • top-0
  • mt-6
  • text-3xl
  • md:text-base
  • py-10
  • md:flex
  • flex-col
  • md:flex-row
  • md:relative
  • bottom-0
  • left-0
  • right-0
  • bg-white
  • md:bg-transparent
  • z-20
  • text-gray-700
  • hover:text-gray-900
  • text-base
  • lg:text-lg
  • pt-10
  • md:pt-0
  • md:ml-5
  • lg:ml-10
  • bg-transparent
  • hover:bg-gray-200
  • border-indigo-700
  • text-indigo-700
  • px-4
  • sm:px-8
  • py-1
  • sm:py-3
  • text-sm
  • bg-gray-100
  • py-12
  • sm:py-24
  • w-11/12
  • sm:w-2/3
  • lg:flex
  • mb-5
  • sm:mb-10
  • text-2xl
  • sm:text-3xl
  • md:text-4xl
  • lg:text-5xl
  • xl:text-6xl
  • text-center
  • text-gray-800
  • mt-5
  • sm:mt-10
  • lg:w-10/12
  • text-gray-400
  • sm:text-lg
  • bg-indigo-700
  • hover:bg-indigo-600
  • lg:text-xl
  • text-white
  • sm:px-10
  • py-2
  • sm:py-4
  • ml-4
  • hover:border-indigo-600
  • hover:text-indigo-600

83 steps to create a Free Tailwind CSS Hero Component component with Tailwind CSS

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

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

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

  4. Control the vertical padding of an element to 0rem at only medium screen sizes using the md:py-0 utilities.

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

  6. Control the horizontal padding of an element to 1.5rem using the px-6 utilities.

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

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

  9. The w-auto utility can be useful if you need to remove an element’s assigned width under a specific condition, like at a particular breakpoint.

  10. Use inline utilities to put the element on its own line and fill its parent at only small screen sizes.

  11. Use hidden to set an element to display: none and remove it from the page layout at only medium screen sizes.

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

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

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

  15. Use inline utilities to put the element on its own line and fill its parent at only medium screen sizes.

  16. Use inline utilities to put the element on its own line and fill its parent at only large screen sizes.

  17. Use hidden to set an element to display: none and remove it from the page layout.

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

  19. Use hidden to set an element to display: none and remove it from the page layout at only large screen sizes.

  20. Use fixed to position an element relative to the browser window.

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

  22. Use the top-0 utilities to set the top position of a positioned element to 0rem.

  23. Control the margin on top side of an element to 1.5rem using the mt-6 utilities.

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

  25. Control the text color of an element to base at only medium screen sizes using the md:text-base utilities.

  26. Control the vertical padding of an element to 2.5rem using the py-10 utilities.

  27. Use flex to create a block-level flex container at only medium screen sizes.

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

  29. Use flex to create a block-level flex container at only medium screen sizes.

  30. Use relative to position an element according to the normal flow of the document at only medium screen sizes.

  31. Use the bottom-0 utilities to set the bottom position of a positioned element to 0rem.

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

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

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

  35. Control the background color of an element to transparent using the md:bg-transparent utilities at only medium screen sizes.

  36. 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.

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

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

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

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

  41. Control the padding on top side of an element to 2.5rem using the pt-10 utilities.

  42. Control the padding on top side of an element to 0rem at only medium screen sizes using the md:pt-0 utilities.

  43. Control the margin on left side of an element to 1.25rem at only medium screen sizes using the md:ml-5 utilities.

  44. Control the margin on left side of an element to 2.5rem at only large screen sizes using the lg:ml-10 utilities.

  45. Control the background color of an element to transparent using the bg-transparent utilities.

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

  47. Control the border color of an element to indigo-700 using the border-indigo-700 utilities.

  48. Control the text color of an element to indigo-700 using the text-indigo-700 utilities.

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

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

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

  52. Control the vertical padding of an element to 0.75rem at only small screen sizes using the sm:py-3 utilities.

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

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

  55. Control the vertical padding of an element to 3rem using the py-12 utilities.

  56. Control the vertical padding of an element to 6rem at only small screen sizes using the sm:py-24 utilities.

  57. Use w-11/12 to set an element to a fixed width(11/12).

  58. Use sm:w-2/3 to set an element to a fixed width(2/3) at only small screen sizes.

  59. Use flex to create a block-level flex container at only large screen sizes.

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

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

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

  63. Control the text color of an element to 3xl at only small screen sizes using the sm:text-3xl utilities.

  64. Control the text color of an element to 4xl at only medium screen sizes using the md:text-4xl utilities.

  65. Control the text color of an element to 5xl at only large screen sizes using the lg:text-5xl utilities.

  66. Control the text color of an element to 6xl at only extremely large screen sizes using the xl:text-6xl utilities.

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

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

  69. Control the margin on top side of an element to 1.25rem using the mt-5 utilities.

  70. Control the margin on top side of an element to 2.5rem at only small screen sizes using the sm:mt-10 utilities.

  71. Use lg:w-10/12 to set an element to a fixed width(10/12) at only large screen sizes.

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

  73. Control the text color of an element to lg at only small screen sizes using the sm:text-lg utilities.

  74. Control the background color of an element to indigo-700 using the bg-indigo-700 utilities.

  75. Control the background color of an element to indigo-600 using the hover:bg-indigo-600 utilities on hover.

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

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

  78. Control the horizontal padding of an element to 2.5rem at only small screen sizes using the sm:px-10 utilities.

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

  80. Control the vertical padding of an element to 1rem at only small screen sizes using the sm:py-4 utilities.

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

  82. Control the border color of an element to indigo-600 using the hover:border-indigo-600 utilities on hover.

  83. Control the text color of an element to indigo-600 on hover using the hover:text-indigo-600 utilities.

Conclusion

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