Check out our free templates made with AI and polished to perfection in Windframe

Get now
Last updated: 4 August 2025

Tailwind Align Items

The align-items property controls how flex or grid container children are aligned vertically (cross axis).


Tailwind Align Items

In CSS Flexbox, the align-items property controls how flex items are vertically aligned inside a flex container along the cross-axis (which is usually vertical).

Tailwind CSS makes this super easy with its utility-first approach. Instead of writing custom CSS, you can simply add an items-{alignment} class to your container.

How to Apply Tailwind Align Items

To apply alignment, add the appropriate items-{alignment} class to your flex container. Here's the basic syntax:

html
<div class="flex items-center">
<!-- Flex items here -->
</div>

Preview

Notice: You must set the container to flex using the flex class. Without it, items-center and similar utilities won't have any effect.

Tailwind Align Items Examples

Let's dive into some simple examples to see how each alignment looks in action

Center Items Vertically

html
<div class="flex items-center">
<div class="bg-blue-500 h-8 w-8">Items 1</div>
<div class="bg-blue-500 h-4 w-4">Items 2</div>
<div class="bg-blue-500 h-6 w-6">Items 3</div>
</div>

Preview

Item 1

items 2

items 3

items-start

Aligns flex items to the start of the container's cross-axis (top for a column layout).

html
<div
class="flex items-start space-x-4 h-40 border border-indigo-100 rounded-t-xl p-4"
>
<div class="bg-indigo-500 text-white p-2 rounded">A</div>
<div class="bg-indigo-500 text-white p-6 rounded">B</div>
<div class="bg-indigo-500 text-white p-10 rounded">C</div>
</div>

Preview

A
B
C

Useful for:

  • Aligning multiple headers at the top.

  • Keeping icons aligned in a sidebar.

items-end

Aligns items to the end (bottom).

html
<div
class="flex items-end space-x-4 h-40 border border-red-100 rounded-t-xl p-4"
>
<div class="bg-red-500 text-white p-2 rounded">A</div>
<div class="bg-red-500 text-white p-6 rounded">B</div>
<div class="bg-red-500 text-white p-10 rounded">C</div>
</div>

Preview

A
B
C

Useful for:

  • Aligning a call-to-action button at the bottom of a card.

  • Creating a sticky footer inside a container.

items-center

Centers items along the cross-axis.

html
<div
class="flex items-center space-x-4 h-40 border border-green-100 rounded-t-xl p-4"
>
<div class="bg-green-500 text-white p-2 rounded">A</div>
<div class="bg-green-500 text-white p-6 rounded">B</div>
<div class="bg-green-500 text-white p-10 rounded">C</div>
</div>

Preview

A
B
C

Useful for:

  • Centering logos in a navbar.

  • Centering profile pictures inside cards.

items-baseline

Aligns flex items along their text baselines.

html
<div
class="flex items-baseline space-x-4 h-40 border border-yellow-100 rounded-t-xl p-4"
>
<div class="bg-yellow-500 text-white text-sm p-2 rounded">Small</div>
<div class="bg-yellow-500 text-white text-xl p-2 rounded">XL</div>
<div class="bg-yellow-500 text-white text-3xl p-2 rounded">3XL</div>
</div>

Preview

Small
XL
3XL

Useful for:

  • Aligning headings and paragraphs neatly.

  • Aligning icons next to text precisely.

items-stretch

Default behavior — stretches flex items to fill the height of the container if no height is set.

html
<div
class="flex items-stretch space-x-4 h-40 border border-blue-100 rounded-t-xl p-4"
>
<div class="bg-blue-500 text-center text-white p-2 w-16 rounded">A</div>
<div class="bg-blue-500 text-center text-white p-6 w-16 rounded">B</div>
<div class="bg-blue-500 text-center text-white p-10 w-16 rounded">C</div>
</div>

Preview

A
B
C

Useful for:

  • Making column grids look consistent.

  • Stretching cards evenly even with different content lengths.

Responsive Tailwind Align Items

Tailwind CSS allows you to apply align items classes responsively at different breakpoints. To use responsive tailwind align items classes, you can append the breakpoint prefix to the utility class. For example, md:items-center applies the center alignment starting from the medium breakpoint and above.

html
<div class="flex items-start md:items-stretch h-40">
<!-- Flex items here -->
</div>

Preview

A
B
C

In the above example, the flex items are aligned to the start of the cross-axis by default (items-start), but starting from the medium breakpoint and above, the alignment is changed to stretch (items-stretch).

Interaction State Use (hover/focus)

There’s no direct interaction-based version of align-items, but you can combine with hover states on containers:

html
<div class="flex hover:items-end items-start transition-all duration-300">
<!-- Children -->
</div>

Preview

A
B
C

This shifts alignment on hover for interactive layout changes.

Arbitrary Value Usage

Tailwind supports arbitrary values via square brackets:

html
<div class="flex [align-items:baseline]">
<!-- ... -->
</div>

Preview

A
B
C

Note: use with caution—stick to standard utilities unless you have a good reason.

Customization in tailwind.config.js

You typically don’t need to customize alignItems, but you can extend it like this:

js
// tailwind.config.js
module.exports = {
theme: {
extend: {
alignItems: {
evenly: "space-evenly",
custom: "10px", // not standard, but useful for experiments
},
},
},
};

Then use it like:

html
<div class="flex items-evenly">
<!-- ... -->
</div>

Real UI Component Example: Chat Bubble Alignment

html
<div class="flex flex-col space-y-2">
<!-- Sender -->
<div class="flex items-start">
<div class="bg-gray-200 rounded-lg p-3 max-w-xs">Hey, how are you?</div>
</div>
<!-- Receiver -->
<div class="flex items-end justify-end">
<div class="bg-blue-500 text-white rounded-lg p-3 max-w-xs">
I'm good, you?
</div>
</div>
</div>

Preview

Hey, how are you?

I'm good, you?

✅ items-start and items-end control how each bubble aligns vertically inside each message block.

Best Practices for Devs & Designers

  • Use items-center in navbars, sidebars, and cards to vertically center content.

  • Combine with justify-\* utilities to control both axes.

  • Avoid arbitrary values unless necessary — stick with standard items-* utilities for consistency.

  • Use responsive utilities (md:items-center) for adapting layout at different breakpoints.

  • Don’t confuse items-* (cross axis) with justify-* (main axis).

Pro Tips for Using Tailwind Align Items

  • Always combine flex with items-{alignment}. Otherwise, it won't work.

  • Use responsive prefixes (sm:, md:, lg:) to adapt your alignment to different devices.

  • Combine with justify-{alignment} classes to control horizontal alignment too!

  • If your items look weird, check their individual heights — flex alignment works relative to the sizes of your flex children.

  • Play with gap-{size} utilities to add spacing between items without messing up their alignment.

Common Mistakes Beginners Make

  • Forgetting the flex container: You must add flex to the parent element.

  • Mixing up flex-direction: Remember, if you use flex-col, the cross-axis becomes horizontal!

  • Overusing center alignment: While centering is useful, aligning content meaningfully can sometimes offer better design structure.

Tailwind Align Items List (Quick Reference)

Here's a handy Tailwind align items list with all the available options:

ClassPropertiesWhat it does
items-startalign-items: flex-startAligns items to the start (top);
items-endalign-items: flex-endAligns items to the end (bottom);
items-centeralign-items: centerCenters items vertically;
items-baselinealign-items: baselineAligns items based on their text baselines;
items-stretchalign-items: stretchStretches items to fill container height;

You'll find yourself using items-center and items-start most often, but knowing all of them gives you great control over your layouts!

Windframe Tailwind blocks

header

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites! 

Build from scratch or select prebuilt tailwind templates