Tailwind CSS Place-self

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

Applying Place Self

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

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

Preview

A
B
C
D
E
F

Responsive Place Self

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

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

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

Tailwind Place Self Class Table

ClassProperties
place-self-autoplace-self: auto;
place-self-startplace-self: start;
place-self-endplace-self: end;
place-self-centerplace-self: center;
place-self-stretchplace-self: 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