Published on

Beginners Guide: Make A Hero Message With Tailwind CSS

Tags
Hero message

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 Hero message ui component

Join us hero message

Why use Tailwind CSS to build a Hero message ui component?

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

The preview of Hero message ui component

Free download of the Hero message's source code

The source code of Hero message ui component

<div class="flex bg-gray-100 py-24 justify-center">
    <div class="p-12 text-center max-w-2xl">
        <div class="md:text-3xl text-3xl font-bold">Want to discover more ?</div>
        <div class="text-xl font-normal mt-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
        </div>
        <div class="mt-6 flex justify-center h-12 relative">
            <div class="flex shadow-md font-medium absolute py-2 px-4 text-green-100
        cursor-pointer bg-green-600 rounded text-lg tr-mt  svelte-jqwywd">Join us now</div>
        </div>
    </div>
</div>

How to build a Hero message with Tailwind CSS?

Install tailwind css of verion 1.3.4

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

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

All the unility class needed to build a Hero message component

  • flex
  • bg-gray-100
  • py-24
  • p-12
  • text-center
  • max-w-2xl
  • md:text-3xl
  • text-3xl
  • text-xl
  • mt-4
  • mt-6
  • h-12
  • relative
  • absolute
  • py-2
  • px-4
  • bg-green-600
  • text-lg

18 steps to build a Hero message component with Tailwind CSS

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

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

  3. Control the vertical padding of an element to 6rem using the py-24 utilities.

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

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

  6. Set the maximum width/height of an element using the max-w-2xl utilities.

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

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

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

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

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

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

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

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

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

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

  17. Control the background color of an element to green-600 using the bg-green-600 utilities.

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

Conclusion

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