Kombai Logo

Tailwind CSS Place Items

The place-items property in CSS is a shorthand for align-items, and justify-items used to align items along both the block axis and the inline axis within a container, primarily in grid layouts. When place-items is used on a flexbox layout, the justify-items property is ignored as it's used on grids.

Tailwind provides a bunch of utility classes to simplify working with with place-items In this guide, we will learn to use these utilities in Tailwind CSS:

ClassPropertiesExample
place-items-startplace-items: start;<div className="place-items-start"></div>
place-items-endplace-items: end;<div className="place-items-end"></div>
place-items-centerplace-items: center;<div className="place-items-center"></div>
place-items-baselineplace-items: baseline;<div className="place-items-baseline"></div>
place-items-stretchplace-items: stretch;<div className="place-items-stretch"></div>

Overview of Place Items

Aligned at the Start

The place-items-start utility aligns the items at the start of both axes of the container. This is perfect for scenarios where you want content to flow naturally to the top-left of its enclosing space.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Above, by using place-items-start, the image stays anchored to the start of the container.

Aligned to the End

When you need content to anchor itself to the bottom-right corner of the container, Tailwind's place-items-end is the appropriate choice. It's useful for creating balanced layouts with content distributed towards a specific edge.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

In this snippet, the place-items-end utility shapes alignment equally to the container boundaries' end along both axes.

Aligned at the Center

For centering elements both vertically and horizontally, place-items-center offers the most straightforward solution in Tailwind. This is ideal for creating visually balanced layouts.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

The content above appears centrally aligned, regardless of the viewport dimensions.

Stretch Alignment

When you need content to span the entire container, place-items-stretch is the ideal utility. Stretch alignment works well for creating uniform layouts, especially in grids with repeating patterns.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

With place-items-stretch, the child element scales with the parent container.

States and Responsiveness

Tailwind supports condition-based alignment utilities. The classes implement alignment changes when a state—such as hover, focus, or active—is triggered. Tailwind also has modifiers sm, md, lg, etc. to target various breakpoints. Let’s explore how you can achieve this.

Hover and Focus States

Change item alignment when an element is hovered. Tailwind's hover:place-items-* syntax allows dynamic and engaging user interfaces.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Here, items move from center to end alignment when hovered.

Breakpoint Modifiers

Tailwind’s breakpoints let you modify alignment properties across varying screen sizes. This is particularly useful for responsive design in complex layouts.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

This demonstrates how layout adjustments for place-items dynamically occur across varying breakpoints.

Real World Examples

Product Showcase Grid

This example demonstrates a grid layout for featuring premium products with place-items-start.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Team Member Directory

This example shows team members' contact information with place-items-end.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Feature Showcase

This example displays feature cards with centered icons using place-items-center.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Testimonial Grid

This example shows testimonials with centered content using place-items-center.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Pricing Cards

This example displays pricing plans with place-items-start.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Best Practices

Balance with Other Layout Properties

Tailwind CSS allows seamless integration of place-items alongside properties like gap, aspect-ratio, and object-fit. When designing media-heavy layouts or interactive elements, such combinations help maintain organized and visually appealing structures. For instance, a card component displaying images and text might use place-items-center for balanced alignment, paired with gap-2 for even spacing between child elements.

If you’re building nested grid structures, combining breadth-specific utilities like place-items-start for outer containers and align-self-center within child elements creates layered, dynamic compositions suited for complex dashboard designs or product showcases.

Accessibility Considerations

Enhance Readability and Navigability

Alignment impacts the user’s ability to quickly scan and interpret content on a page. Ensure place-items usage contributes to logical flow by aligning elements naturally within their container. For example, use place-items-start to anchor critical content to predictable locations, such as the top-left corner for introductory sections.

Promote readability by aligning text-based content consistently. Pair place-items with subtle spacing utilities like p-4 and ensure sufficient whitespace. For instance, in testimonial cards, place-items-center ensures quotes are both visually centralized and easy to navigate cognitively.

When aligning interactive elements, favor central alignment in smaller containers to group and highlight components effectively. This ensures users don’t struggle to distinguish or locate actionable content.