- Published on
Most Effective Ways To Build A Footer With Collapsing Sections With Tailwind CSS

- What is Tailwind CSS?
- The description of Footer with collapsing sections ui component
- Why use Tailwind CSS to make a Footer with collapsing sections ui component?
- The preview of Footer with collapsing sections ui component
- The source code of Footer with collapsing sections ui component
- How to make a Footer with collapsing sections with Tailwind CSS?
- Install tailwind css of verion 1.4.6
- All the unility class needed to make a Footer with collapsing sections component
- 44 steps to make a Footer with collapsing sections component with Tailwind CSS
- Conclusion
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 Footer with collapsing sections ui component
Inspired by fashion sites like lululemon, best for sites that need a lot of info in the footer. at mobile widths the sections will collapse (requires javascript to toggle visibility).
Why use Tailwind CSS to make a Footer with collapsing sections ui component?
- It can make the building process of Footer with collapsing sections ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Footer with collapsing sections component file.
The preview of Footer with collapsing sections ui component
Free download of the Footer with collapsing sections's source code
The source code of Footer with collapsing sections ui component
<footer class="mt-16">
<div class="border-t md:px-4 md:pt-10 md:pb-5">
<div class="flex flex-wrap md:max-w-screen-lg mx-auto">
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Lorem ipsum dolor sit amet consectetur adipiscing elit maecenas
mattis
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Lorem ipsum dolor sit amet consectetur adipiscing elit maecenas
mattis
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Fusce vel sem</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Ut venenatis tellus</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Vestibulum</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Nunc at ipsum</a>
</li>
</ul>
</article>
</section>
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Ut porta
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Ut porta
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Pellentesque rhoncus</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Aenean</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Curabitur bibendum</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Phasellus non mi</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Duis accumsa</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Curabitur nec enim</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Fusce ut augue</a>
</li>
</ul>
</article>
</section>
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Praesent elementum
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Praesent elementum
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Mauris mattis nunc</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Nunc viverra risus</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Etiam a libero</a>
</li>
</ul>
</article>
</section>
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Aenean gravida orci in sem varius
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Aenean gravida orci in sem varius
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Cras id ipsum</a>
</li>
</ul>
</article>
</section>
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Donec a lorem
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Donec a lorem
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Sed a diam</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Nullam luctus felis</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Sed euismod</a>
</li>
</ul>
</article>
</section>
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Integer interdum
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Integer interdum
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Dignissim gravida</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Eu mollis elit</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Hendrerit purus id</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Ut luctus dui tincidunt</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Pellentesque at ligula</a>
</li>
</ul>
</article>
</section>
<section
class="relative text-gray-700 font-light font-light border-b px-4 pb-4 md:py-3 w-full md:border-none md:w-1/4"
>
<div class="md:hidden">
<button
onclick="toggleFooterSection(event)"
class="uppercase text-xs font-bold tracking-wider text-pink-700 focus:outline-none border-t border-white py-4 w-full text-left"
type="button"
>
Quisque
</button>
</div>
<a
class="uppercase text-xs font-bold tracking-wider text-pink-700 hidden md:block"
href="#"
>
Quisque
</a>
<article class="h-0 md:h-auto -mt-4 md:mt-0 overflow-hidden">
<ul class="my-5 text-sm tracking-wide">
<li class="my-3 tracking-wide">
<a href="#">Finibus nulla eget</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Pellentesque</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Duis efficitur</a>
</li>
<li class="my-3 tracking-wide">
<a href="#">Cras at lacus</a>
</li>
</ul>
</article>
</section>
</div>
</div>
<div class="max-w-screen-lg mx-auto border-none px-4">
<section
class="flex flex-col md:flex-row md:justify-between md:border-solid md:border-t text-gray-700 font-light text-sm pt-4 pb-6 md:pt-5 md:pb-6 w-full"
>
<div>
<p class="leading-8 tracking-wide">
© Lorem Ipsum Co., 123 Lorem Street, New York, NY
</p>
</div>
<div>
<p class="leading-8 tracking-wide">Privacy Policy</p>
</div>
</section>
</div>
</footer>
<script>
function toggleFooterSection(e) {
const list = e.target.parentElement.parentElement.querySelector(
"article"
);
if (list.classList.contains("h-0")) {
list.classList.remove("h-0");
} else {
list.classList.add("h-0");
}
}
</script>
How to make a Footer with collapsing sections with Tailwind CSS?
Install tailwind css of verion 1.4.6
Use the link
html tag to import the stylesheet of Tailwind CSS of the version 1.4.6
<link href=https://unpkg.com/[email protected]/dist/tailwind.min.css rel="stylesheet">
All the unility class needed to make a Footer with collapsing sections component
mt-16
border-t
md:px-4
md:pt-10
md:pb-5
flex
flex-wrap
md:max-w-screen-lg
mx-auto
relative
text-gray-700
border-b
px-4
pb-4
md:py-3
w-full
md:border-none
md:w-1/4
md:hidden
text-xs
text-pink-700
border-white
py-4
text-left
hidden
md:block
h-0
md:h-auto
-mt-4
md:mt-0
overflow-hidden
my-5
text-sm
my-3
max-w-screen-lg
border-none
flex-col
md:flex-row
md:border-solid
md:border-t
pt-4
pb-6
md:pt-5
md:pb-6
44 steps to make a Footer with collapsing sections component with Tailwind CSS
Control the margin on top side of an element to 4rem using the
mt-16
utilities.Control the border color of an element to t using the
border-t
utilities.Control the horizontal padding of an element to 1rem at only medium screen sizes using the
md:px-4
utilities.Control the padding on top side of an element to 2.5rem at only medium screen sizes using the
md:pt-10
utilities.Control the padding on bottom side of an element to 1.25rem at only medium screen sizes using the
md:pb-5
utilities.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Set the maximum width/height of an element using the
md:max-w-screen-lg
utilities at only medium screen sizes.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Use
relative
to position an element according to the normal flow of the document.Control the text color of an element to gray-700 using the
text-gray-700
utilities.Control the border color of an element to b using the
border-b
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the padding on bottom side of an element to 1rem using the
pb-4
utilities.Control the vertical padding of an element to 0.75rem at only medium screen sizes using the
md:py-3
utilities.Use
w-full
to set an element to a 100% based width.Control the border color of an element to none using the
md:border-none
utilities at only medium screen sizes.Use
md:w-1/4
to set an element to a fixed width(1/4) at only medium screen sizes.Use
hidden
to set an element to display: none and remove it from the page layout at only medium screen sizes.Control the text color of an element to xs using the
text-xs
utilities.Control the text color of an element to pink-700 using the
text-pink-700
utilities.Control the border color of an element to white using the
border-white
utilities.Control the vertical padding of an element to 1rem using the
py-4
utilities.Control the text color of an element to left using the
text-left
utilities.Use
hidden
to set an element to display: none and remove it from the page layout.Use
inline
utilities to put the element on its own line and fill its parent at only medium screen sizes.Use
h-0
to set an element to a fixed height(0rem).Use
md:h-auto
to set an element to a fixed height(auto) at only medium screen sizes.Control the margin on top side of an element to -1rem using the
-mt-4
utilities.Control the margin on top side of an element to 0rem at only medium screen sizes using the
md:mt-0
utilities.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Control the vertical margin of an element to 1.25rem using the
my-5
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the vertical margin of an element to 0.75rem using the
my-3
utilities.Set the maximum width/height of an element using the
max-w-screen-lg
utilities.Control the border color of an element to none using the
border-none
utilities.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container at only medium screen sizes.Control the border color of an element to solid using the
md:border-solid
utilities at only medium screen sizes.Control the border color of an element to t using the
md:border-t
utilities at only medium screen sizes.Control the padding on top side of an element to 1rem using the
pt-4
utilities.Control the padding on bottom side of an element to 1.5rem using the
pb-6
utilities.Control the padding on top side of an element to 1.25rem at only medium screen sizes using the
md:pt-5
utilities.Control the padding on bottom side of an element to 1.5rem at only medium screen sizes using the
md:pb-6
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to make a Footer with collapsing sections components, learn and follow along to implement your own components.