Tailwind Align Self
The align-self utility class in Tailwind CSS allows you to control the vertical alignment of individual flex items within a flex containers.
Tailwind Align Self
The align-self
utility class in Tailwind CSS allows you to control the vertical alignment of individual flex items within a flex container. With Tailwind align-self class, you can easily adjust the positioning of specific flex items along the cross-axis, overriding the default alignment set by the flex container.
Applying Tailwind Align Self
To apply the alignment to a specific flex item, you can use the tailwind self-{alignment}
utility class, where {alignment}
represents the desired alignment. Here are the available alignment options:
self-auto
: Resets the alignment to the value set by the flex container.self-start
: Aligns the flex item to the start of the cross-axis.self-end
: Aligns the flex item to the end of the cross-axis.self-center
: Aligns the flex item to the center of the cross-axis.self-baseline
: Aligns the flex item to the baseline of the cross-axis.self-stretch
: Stretches the flex item to fill the cross-axis.
<div class="flex"> <div class="bg-purple-500 h-8 w-8 self-start">Item 1</div> <div class="bg-purple-500 h-4 w-4 self-end">Item 2</div> <div class="bg-purple-500 h-6 w-6 self-center">Item 3</div></div>
Preview
Item 1
item 2
item 3
Responsive Tailwind Align Self
Tailwind CSS allows you to apply align self classes responsively at different breakpoints. To use responsive tailwind align self classes, you can append the breakpoint prefix to the utility class. For example, md:self-center
applies the center alignment starting from the medium breakpoint and above.
<div class="flex"> <div class="bg-gray-200 h-8 w-8 self-start md:self-center"></div> <!-- Other flex items --></div>
In the above example, the first flex item is aligned to the start of the cross-axis by default (self-start)
, but starting from the medium breakpoint and above, the alignment is changed to center (self-center)
.
Tailwind Align-self class Table
Class | Properties |
---|---|
self-auto | align-self: auto; |
self-start | align-self: flex-start; |
self-end | align-self: flex-end; |
self-center | align-self: center; |
self-stretch | align-self: stretch; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs