components
Tailwind CSS Stack
Stack elements positions them on top of each other in a visual manner.
The following example displays div’s without stacking.
<div>
<div class="bg-primary text-primary-content grid h-20 w-32 place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid h-20 w-32 place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid h-20 w-32 place-content-center rounded-sm">3</div>
</div>
Wrap the stacked div’s with a wrapper div using the component class stack
.
<div class="stack h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-animated to enable animation on hover.
<div class="stack stack-bottom-start stack-animated h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
By default, the stacking direction is from the bottom.
<div class="stack h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-bottom-start
to set the stack direction to bottom-start.
<div class="stack stack-bottom-start h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-bottom-end
to set the stack direction to bottom-end.
<div class="stack stack-bottom-end h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-top
to set the stack direction to top.
<div class="stack stack-top h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-top-start
to set the stack direction to top-start.
<div class="stack stack-top-start h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-top-end
to set the stack direction to stack-end.
<div class="stack stack-top-end h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-start
to set the stack direction to start.
<div class="stack stack-start h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
Apply the modifier class stack-end
to set the stack direction to end.
<div class="stack stack-end h-20 w-32">
<div class="bg-primary text-primary-content grid place-content-center rounded-sm">1</div>
<div class="bg-success text-success-content grid place-content-center rounded-sm">2</div>
<div class="bg-warning text-warning-content grid place-content-center rounded-sm">3</div>
</div>
The example below demonstrates a stack with images.



<div class="stack w-32">
<img src="https://cdn.flyonui.com/fy-assets/components/card/image-1.png" alt="iphone" class="rounded-sm" />
<img src="https://cdn.flyonui.com/fy-assets/components/card/image-2.png" alt="sydney" class="rounded-sm" />
<img src="https://cdn.flyonui.com/fy-assets/components/card/image-3.png" alt="rome" class="rounded-sm" />
</div>
The example below demonstrates a stack with cards.
Card A
Card B
Card C
<div class="stack w-32">
<div class="card border-base-content border shadow-none">
<div class="card-body text-center">
<p>Card A</p>
</div>
</div>
<div class="card border-base-content border shadow-none">
<div class="card-body text-center">
<p>Card B</p>
</div>
</div>
<div class="card border-base-content border shadow-none">
<div class="card-body text-center">
<p>Card C</p>
</div>
</div>
</div>
The example below demonstrates a notifications stack.
3 Notifications
You have 3 unread messages. Tap here to see.
2 Notifications
You have 2 unread messages. Tap here to see.
Notification 1
You have an unread message. Tap here to see.
<div class="stack stack-animated">
<div class="card bg-primary text-primary-content shadow-none">
<div class="card-body">
<h5 class="card-title text-primary-content">3 Notifications</h5>
<p>You have 3 unread messages. Tap here to see.</p>
</div>
</div>
<div class="card bg-info text-info-content shadow-none">
<div class="card-body">
<h5 class="card-title text-info-content">2 Notifications</h5>
<p>You have 2 unread messages. Tap here to see.</p>
</div>
</div>
<div class="card bg-secondary text-secbg-secondary-content shadow-none">
<div class="card-body">
<h5 class="card-title text-secbg-secondary-content">Notification 1</h5>
<p>You have an unread message. Tap here to see.</p>
</div>
</div>
</div>