Published on

How To Make A Story component With Tailwind CSS From Scratch

Tags
Story 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 Story component ui component

I have created a story component similar to instagram that you can use on your own web app.

thank you.

Why use Tailwind CSS to make a Story component ui component?

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

The preview of Story component ui component

Free download of the Story component's source code

The source code of Story component ui component

<section class="bg-black min-h-screen md:flex flex-col items-center justify-center">
        <div class="pt-10 pb-10">
            <h2 class="text-4xl font-bold text-center text-pink-700">Instagram story</h2>
        </div>
        <ul class="md:flex items-center justify-center md:space-x-8">
            <li class="flex flex-col items-center space-y-2">
                <div class="bg-gradient-to-tr from-yellow-500 to-pink-600 rounded-full p-1 relative">
                    <a class="block bg-white p-1 rounded-full transform transition hover:-rotate-12 duration-300" href="#">
                        <img class="h-24 w-24 rounded-full" src="https://i.ibb.co/yhh0Ljy/profile.jpg" alt="image">
                    </a>
                    <button class="transition duration-500 absolute bottom-0 right-0 bg-blue-700 h-8 w-8 rounded-full text-white text-2xl font-semibold border-4 border-white flex justify-center items-center hover:bg-blue-900">+</button>
                </div>
                <p>you</p>
            </li>
            <li class="flex flex-col items-center space-y-2">
                <div class="bg-gradient-to-tr from-yellow-500 to-pink-600 rounded-full p-1">
                    <a class="block bg-white p-1 rounded-full transform transition hover:-rotate-12 duration-300" href="#">
                        <img class="h-24 w-24 rounded-full" src="https://i.ibb.co/yhh0Ljy/profile.jpg" alt="image">
                    </a>
                </div>
                <p>tahmina_tis_353</p>
            </li>
            <li class="flex flex-col items-center space-y-2">
                <div class="bg-gradient-to-tr from-yellow-500 to-pink-600 rounded-full p-1">
                    <a class="block bg-white p-1 rounded-full transform transition hover:-rotate-12 duration-300" href="#">
                        <img class="h-24 w-24 rounded-full" src="https://i.ibb.co/yhh0Ljy/profile.jpg" alt="image">
                    </a>
                </div>
                <p>Adiba_3883</p>
            </li>
            <li class="flex flex-col items-center space-y-2">
                <div class="bg-gradient-to-tr from-yellow-500 to-pink-600 rounded-full p-1">
                    <a class="block bg-white p-1 rounded-full transform transition hover:-rotate-12 duration-300" href="#">
                        <img class="h-24 w-24 rounded-full" src="https://i.ibb.co/yhh0Ljy/profile.jpg" alt="image">
                    </a>
                </div>
                <p>forhadx_9008</p>
            </li>
            <li class="flex flex-col items-center space-y-2">
                <div class="bg-gradient-to-tr from-yellow-500 to-pink-600 rounded-full p-1">
                    <a class="block bg-white p-1 rounded-full transform transition hover:-rotate-12 duration-300" href="#">
                        <img class="h-24 w-24 rounded-full" src="https://i.ibb.co/yhh0Ljy/profile.jpg" alt="image">
                    </a>
                </div>
                <p>shahnoor_877</p>
            </li>
        </ul>
    </section>

How to make a Story component with Tailwind CSS?

Install tailwind css of verion 1.9.6

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

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

All the unility class needed to make a Story component component

  • bg-black
  • min-h-screen
  • md:flex
  • flex-col
  • pt-10
  • pb-10
  • text-4xl
  • text-center
  • text-pink-700
  • flex
  • bg-gradient-to-tr
  • p-1
  • relative
  • block
  • bg-white
  • h-24
  • w-24
  • absolute
  • bottom-0
  • right-0
  • bg-blue-700
  • h-8
  • w-8
  • text-white
  • text-2xl
  • border-4
  • border-white
  • hover:bg-blue-900

28 steps to make a Story component component with Tailwind CSS

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

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

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

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

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

  6. Control the padding on bottom side of an element to 2.5rem using the pb-10 utilities.

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

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

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

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

  11. Control the background color of an element to gradient-to-tr using the bg-gradient-to-tr utilities.

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

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

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

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

  16. Use h-24 to set an element to a fixed height(6rem).

  17. Use w-24 to set an element to a fixed width(6rem).

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

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

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

  21. Control the background color of an element to blue-700 using the bg-blue-700 utilities.

  22. Use h-8 to set an element to a fixed height(2rem).

  23. Use w-8 to set an element to a fixed width(2rem).

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

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

  26. Control the border color of an element to 1rem using the border-4 utilities.

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

  28. Control the background color of an element to blue-900 using the hover:bg-blue-900 utilities on hover.

Conclusion

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