Tailwind CSS Place-items

The place-items utility class in Tailwind CSS allows you to control the alignment and spacing of grid or flex container items both horizontally and vertically. With Tailwind's place-items class, you can easily position and align individual items within a container.

Applying Place Items

To apply the alignment and spacing to individual items within a grid or flex container, you can use the place-items-{alignment} utility class, where {alignment} represents the desired alignment. Here are the available alignment options:

  • place-items-start: Aligns items to the start of both the horizontal and vertical axes.
  • place-items-end: Aligns items to the end of both the horizontal and vertical axes.
  • place-items-center: Aligns items to the center of both the horizontal and vertical axes.
  • place-items-stretch: Stretches items to fill the container along both axes.
  • place-items-auto: Applies automatic item placement, allowing items to be positioned based on their default placement rules.
html
<div class="grid place-items-center">
<div>A</div>
<div>B</div>
<div>C</div>
<div>D</div>
<div>E</div>
<div>F</div>
</div>

Preview

A
B
C
D
E
F

Responsive Place Items

Tailwind CSS allows you to apply place items classes responsively at different breakpoints. To use responsive place items classes, you can append the breakpoint prefix to the utility class. For example, md:place-items-stretch stretches the items to fill the container along both axes starting from the medium breakpoint and above.

html
<div class="grid place-items-start md:place-items-stretch">
<!-- Grid items here -->
</div>

In the above example, the items are aligned to the start of both axes by default (place-items-start), but starting from the medium breakpoint and above, the items are stretched to fill the container (md:place-items-stretch).

Tailwind Place-items Class Table

ClassProperties
place-items-autoplace-items: auto;
place-items-startplace-items: start;
place-items-endplace-items: end;
place-items-centerplace-items: center;
place-items-stretchplace-items: stretch;

Windframe Tailwind blocks

footer

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner