Display & flex
Show and hide things, lay them in rows or columns, and line them up. All of these have screen-size versions: hidden md:block hides on phones and shows from 768px.
Rows and columns
DesignResearchWritingCode
<div class="flex flex-wrap gap-2">
<span class="tag">Design</span><span class="tag">Research</span><span class="tag">Writing</span><span class="tag">Code</span>
</div>
<div class="flex flex-col gap-2 mt-4 max-w-xs">
<button class="btn btn-block" type="button">Continue with email</button>
<button class="btn btn-block btn-ghost" type="button">I have an account</button>
</div>Push apart, center, fill
justify-between sends the first and last child to the ends; ms-auto on one child pushes it (and everything after) to the end. flex-1 makes a child take the leftover room.
Notifications4
<div class="flex items-center gap-3 p-3 box">
<i class="mi mi-search text-muted" aria-hidden="true"></i>
<input class="form-control flex-1" placeholder="Search projects" aria-label="Search projects">
<button class="btn btn-brand" type="button">Search</button>
</div>
<div class="flex items-center gap-2 p-3 box mt-3">
<b>Notifications</b><span class="badge badge-count">4</span>
<button class="btn btn-sm btn-ghost ms-auto" type="button">Mark all read</button>
</div>Show on some screens
You are on a small screen.
You are on a screen 768px or wider.
<div class="box p-4">
<span class="md:hidden">You are on a small screen.</span>
<span class="hidden md:inline">You are on a screen 768px or wider.</span>
</div>hidden removes an element from the page and from screen readers. To hide something only visually, use visually-hidden.
Display
| Class | CSS |
|---|---|
block | display: block; |
inline-block | display: inline-block; |
inline | display: inline; |
flex | display: flex; |
inline-flex | display: inline-flex; |
grid | display: grid; |
inline-grid | display: inline-grid; |
contents | display: contents; |
flow-root | display: flow-root; |
hidden | display: none; |
Flex
| Class | CSS |
|---|---|
flex-row | flex-direction: row; |
flex-col | flex-direction: column; |
flex-row-reverse | flex-direction: row-reverse; |
flex-col-reverse | flex-direction: column-reverse; |
flex-wrap | flex-wrap: wrap; |
flex-nowrap | flex-wrap: nowrap; |
flex-wrap-reverse | flex-wrap: wrap-reverse; |
flex-1 | flex: 1 1 0%; |
flex-auto | flex: 1 1 auto; |
flex-initial | flex: 0 1 auto; |
flex-none | flex: none; |
grow | flex-grow: 1; |
grow-0 | flex-grow: 0; |
shrink | flex-shrink: 1; |
shrink-0 | flex-shrink: 0; |
order-first | order: -9999; |
order-last | order: 9999; |
order-none | order: 0; |
order-1 | order: 1; |
order-2 | order: 2; |
order-3 | order: 3; |
order-4 | order: 4; |
order-5 | order: 5; |
order-6 | order: 6; |
Alignment
Works in flex and grid boxes. items-* lines children up across the row, justify-* along it, self-* moves one child.
| Class | CSS |
|---|---|
items-start | align-items: flex-start; |
items-center | align-items: center; |
items-end | align-items: flex-end; |
items-stretch | align-items: stretch; |
items-baseline | align-items: baseline; |
self-start | align-self: flex-start; |
self-center | align-self: center; |
self-end | align-self: flex-end; |
self-stretch | align-self: stretch; |
self-baseline | align-self: baseline; |
self-auto | align-self: auto; |
justify-start | justify-content: flex-start; |
justify-center | justify-content: center; |
justify-end | justify-content: flex-end; |
justify-between | justify-content: space-between; |
justify-around | justify-content: space-around; |
justify-evenly | justify-content: space-evenly; |
justify-stretch | justify-content: stretch; |
content-start | align-content: flex-start; |
content-center | align-content: center; |
content-end | align-content: flex-end; |
content-between | align-content: space-between; |
content-around | align-content: space-around; |
content-evenly | align-content: space-evenly; |
content-stretch | align-content: stretch; |
justify-items-start | justify-items: start; |
justify-items-center | justify-items: center; |
justify-items-end | justify-items: end; |
justify-items-stretch | justify-items: stretch; |
justify-self-auto | justify-self: auto; |
justify-self-start | justify-self: start; |
justify-self-center | justify-self: center; |
justify-self-end | justify-self: end; |
justify-self-stretch | justify-self: stretch; |
place-items-start | place-items: start; |
place-items-center | place-items: center; |
place-items-end | place-items: end; |
place-items-stretch | place-items: stretch; |
place-items-baseline | place-items: baseline; |
place-content-start | place-content: start; |
place-content-center | place-content: center; |
place-content-end | place-content: end; |
place-content-between | place-content: space-between; |
place-content-around | place-content: space-around; |
place-content-evenly | place-content: space-evenly; |
place-content-stretch | place-content: stretch; |
place-self-auto | place-self: auto; |
place-self-start | place-self: start; |
place-self-center | place-self: center; |
place-self-end | place-self: end; |
place-self-stretch | place-self: stretch; |