Published on

Surprisingly Effective Ways To Build A Story Bar With Tailwind CSS

Story Bar

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 Bar ui component

Story bar tempate like instagram

Why use Tailwind CSS to create a Story Bar ui component?

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

The preview of Story Bar ui component

Free download of the Story Bar's source code

The source code of Story Bar ui component

<!-- MDI Icons -->
<link rel="stylesheet" href="//cdn.materialdesignicons.com/6.5.95/css/materialdesignicons.min.css">


<style>
    .story-ring {
        padding: 2px;
    }

    .story-text {
        font-size: 13px;
    }
</style>

<!-- Story Bar Container -->
<div class="flex flex-col items-center justify-center">
    <span class="text-center font-bold my-20">
        MDI (npm i @mdi/font) reuqired for plus icon

        <hr class="my-4">

        <a href="https://egoistdeveloper.github.io/twcss-to-sass-playground/" target="_blank" class="text-blue-600">
            Convetert to SASS
        </a>
    </span>

    <div class="w-full max-w-md px-7 py-10 mx-auto bg-white rounded-2xl shadow-xl">
        <div class="flex flex-col">
            <div class="flex">
                <!-- Story Bar -->
                <ul class="flex items-center justify-center space-x-2">
                    <!-- Add Story -->
                    <li class="flex flex-col items-center space-y-2">
                        <!-- Ring -->
                        <div class="story-ring flex justify-center items-center
                                bg-gradient-to-tl from-yellow-200 to-orange-500 
                                rounded-full relative cursor-pointer
                                hover:from-orange-300 hover:to-red-400
                                transition-all duration-150 delay-100">
                            <a class="block bg-white p-1 rounded-full" href="#">
                                <!-- Thumbnail -->
                                <img class="w-16 rounded-full"
                                    src="https://images.unsplash.com/photo-1638687110777-b3fcdf2f9c57?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&h=200&q=80">
                            </a>

                            <button class="absolute transition duration-500 bg-white border-gray-400 
                                    h-8 w-8 rounded-full text-white border-2 
                                    border-white flex justify-center items-center opacity-80
                                    hover:opacity-60">
                            </button>

                            <i class="absolute mdi mdi-plus mdi-18px mx-1 text-gray-500"></i>
                        </div>

                        <!-- Username -->
                        <span class="story-text font-medium">
                            You
                        </span>
                    </li>

                    <!-- Story #1 -->
                    <li class="flex flex-col items-center space-y-2">
                        <!-- Ring -->
                        <div class="story-ring flex justify-center items-center
                                bg-gradient-to-tl from-yellow-200 to-orange-500 
                                rounded-full relative cursor-pointer
                                hover:from-orange-300 hover:to-red-400
                                transition-all duration-150 delay-100">
                            <a class="block bg-white p-1 rounded-full" href="#">
                                <!-- Thumbnail -->
                                <img class="w-16 rounded-full"
                                    src="https://images.unsplash.com/photo-1638649602320-450b717fa622?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&h=200&q=80">
                            </a>
                        </div>

                        <!-- Username -->
                        <span class="story-text">
                            jett
                        </span>
                    </li>

                    <!-- Story #2 -->
                    <li class="flex flex-col items-center space-y-2">
                        <!-- Ring -->
                        <div class="story-ring flex justify-center items-center
                                bg-gradient-to-tl from-yellow-200 to-orange-500 
                                rounded-full relative cursor-pointer
                                hover:from-orange-300 hover:to-red-400
                                transition-all duration-150 delay-100">
                            <a class="block bg-white p-1 rounded-full" href="#">
                                <!-- Thumbnail -->
                                <img class="w-16 rounded-full"
                                    src="https://images.unsplash.com/photo-1638708644743-2502f38000a0?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&h=200&q=80">
                            </a>
                        </div>

                        <!-- Username -->
                        <span class="story-text">
                            sky
                        </span>
                    </li>

                    <!-- Story #3 -->
                    <li class="flex flex-col items-center space-y-2">
                        <!-- Ring -->
                        <div class="story-ring flex justify-center items-center
                                bg-gradient-to-tl from-yellow-200 to-orange-500 
                                rounded-full relative cursor-pointer
                                hover:from-orange-300 hover:to-red-400
                                transition-all duration-150 delay-100">
                            <a class="block bg-white p-1 rounded-full" href="#">
                                <!-- Thumbnail -->
                                <img class="w-16 rounded-full"
                                    src="https://images.unsplash.com/photo-1638691899851-0e955bceba1f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&h=200&q=80">
                            </a>
                        </div>

                        <!-- Username -->
                        <span class="story-text">
                            omen
                        </span>
                    </li>

                    <!-- Story #4 -->
                    <li class="flex flex-col items-center space-y-2">
                        <!-- Ring -->
                        <div class="story-ring flex justify-center items-center
                                bg-gradient-to-tl from-yellow-200 to-orange-500 
                                rounded-full relative cursor-pointer
                                hover:from-orange-300 hover:to-red-400
                                transition-all duration-150 delay-100 
                                hover:animate-pulse">
                            <a class="block bg-white p-1 rounded-full" href="#">
                                <img class="w-16 rounded-full"
                                    src="https://images.unsplash.com/photo-1638612913771-8f00622b96fb?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&h=200&q=80">
                            </a>
                        </div>

                        <!-- Username -->
                        <span class="story-text">
                            sage
                        </span>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

How to create a Story Bar 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 Story Bar component

  • flex
  • flex-col
  • text-center
  • my-20
  • my-4
  • text-blue-600
  • w-full
  • max-w-md
  • px-7
  • py-10
  • mx-auto
  • bg-white
  • bg-gradient-to-tl
  • relative
  • block
  • p-1
  • w-16
  • absolute
  • border-gray-400
  • h-8
  • w-8
  • text-white
  • border-2
  • border-white
  • mx-1
  • text-gray-500

26 steps to create a Story Bar component with Tailwind CSS

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

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

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

  4. Control the vertical margin of an element to 5rem using the my-20 utilities.

  5. Control the vertical margin of an element to 1rem using the my-4 utilities.

  6. Control the text color of an element to blue-600 using the text-blue-600 utilities.

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

  8. Set the maximum width/height of an element using the max-w-md utilities.

  9. Control the horizontal padding of an element to 1.75rem using the px-7 utilities.

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

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

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

  13. Control the background color of an element to gradient-to-tl using the bg-gradient-to-tl utilities.

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

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

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

  17. Use w-16 to set an element to a fixed width(4rem).

  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. Control the border color of an element to gray-400 using the border-gray-400 utilities.

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

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

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

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

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

  25. Control the horizontal margin of an element to 0.25rem using the mx-1 utilities.

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

Conclusion

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