Skip to main content

Display

Control how elements are displayed with our display utilities.

Display Properties

.blockBlockdisplay: block;Full-width block element
.inline-blockInline-blockdisplay: inline-block;Inline with block properties
.flexFlexdisplay: flex;Flexbox container
.inline-flexInline-flexdisplay: inline-flex;Inline flexbox container
.hiddenHiddendisplay: none;Hide element

Examples

<!-- Display examples -->
<div class="block p-4 bg-gray-light">Block element</div>
<span class="inline-block p-2 bg-blue text-white">Inline block</span>
<div class="flex items-center gap-4">Flex container</div>
<div class="inline-flex items-center gap-2">Inline flex</div>
<div class="hidden">This is hidden</div>

Overflow

Control how content overflows its container.

Overflow Properties

.overflow-hiddenHiddenoverflow: hidden;Hide overflowing content
.overflow-autoAutooverflow: auto;Show scrollbars when needed

Examples

<!-- Overflow examples -->
<div class="w-64 h-32 overflow-hidden border border-gray">
  <p class="p-4">
    This content might overflow the container and will be hidden.
  </p>
</div>

<div class="w-64 h-32 overflow-auto border border-gray">
  <p class="p-4">This content will show scrollbars when it overflows.</p>
</div>

Object Fit

Control how images and videos fit within their containers.

Object Fit Properties

.object-coverCoverobject-fit: cover;Cover container, crop if needed
.object-containContainobject-fit: contain;Fit within container, no cropping

Examples

<!-- Object fit examples -->
<img src="image.jpg" class="w-64 h-32 object-cover rounded" alt="Cover image" />
<img
  src="image.jpg"
  class="w-64 h-32 object-contain border"
  alt="Contain image"
/>

Aspect Ratio

Control the aspect ratio of elements.

Aspect Ratio Properties

.aspect-square1:1aspect-ratio: 1 / 1;Square aspect ratio
.aspect-video16:9aspect-ratio: 16 / 9;Video aspect ratio

Examples

<!-- Aspect ratio examples -->
<div class="w-64 aspect-square bg-blue rounded"></div>
<div class="w-full aspect-video bg-gray-light rounded"></div>

Flexbox Direction

Control the direction of flex items.

Flex Direction

.flex-rowRowflex-direction: row;Horizontal layout (default)
.flex-colColumnflex-direction: column;Vertical layout

Examples

<!-- Flex direction examples -->
<div class="flex flex-row gap-4">
  <div class="p-4 bg-blue text-white">Item 1</div>
  <div class="p-4 bg-green text-white">Item 2</div>
  <div class="p-4 bg-red text-white">Item 3</div>
</div>

<div class="flex flex-col gap-4">
  <div class="p-4 bg-blue text-white">Item 1</div>
  <div class="p-4 bg-green text-white">Item 2</div>
  <div class="p-4 bg-red text-white">Item 3</div>
</div>

Flexbox Wrap

Control how flex items wrap.

Flex Wrap

.flex-wrapWrapflex-wrap: wrap;Allow wrapping
.flex-nowrapNo wrapflex-wrap: nowrap;Prevent wrapping

Examples

<!-- Flex wrap examples -->
<div class="flex flex-wrap gap-4">
  <div class="w-1-3 p-4 bg-blue text-white">Item 1</div>
  <div class="w-1-3 p-4 bg-green text-white">Item 2</div>
  <div class="w-1-3 p-4 bg-red text-white">Item 3</div>
  <div class="w-1-3 p-4 bg-yellow text-white">Item 4</div>
</div>

Justify Content

Control horizontal alignment of flex items.

Justify Content

.justify-startStartjustify-content: start;Align to start
.justify-centerCenterjustify-content: center;Center alignment
.justify-endEndjustify-content: end;Align to end
.justify-betweenSpace betweenjustify-content: space-between;Space between items

Examples

<!-- Justify content examples -->
<div class="flex justify-start gap-4 p-4 bg-gray-light">
  <div class="p-2 bg-blue text-white">Start</div>
  <div class="p-2 bg-green text-white">Items</div>
</div>

<div class="flex justify-center gap-4 p-4 bg-gray-light">
  <div class="p-2 bg-blue text-white">Centered</div>
  <div class="p-2 bg-green text-white">Items</div>
</div>

<div class="flex justify-between p-4 bg-gray-light">
  <div class="p-2 bg-blue text-white">Start</div>
  <div class="p-2 bg-green text-white">End</div>
</div>

Align Items

Control vertical alignment of flex items.

Align Items

.items-startStartalign-items: start;Align to start
.items-centerCenteralign-items: center;Center alignment
.items-endEndalign-items: end;Align to end
.items-stretchStretchalign-items: stretch;Stretch to fill

Examples

<!-- Align items examples -->
<div class="flex items-start gap-4 p-4 bg-gray-light h-24">
  <div class="p-2 bg-blue text-white">Start</div>
  <div class="p-2 bg-green text-white">Aligned</div>
</div>

<div class="flex items-center gap-4 p-4 bg-gray-light h-24">
  <div class="p-2 bg-blue text-white">Center</div>
  <div class="p-2 bg-green text-white">Aligned</div>
</div>

Align Self

Control individual item alignment within a flex container.

Align Self

.self-centerCenteralign-self: center;Center this item
.self-startStartalign-self: start;Align to start
.self-endEndalign-self: end;Align to end

Examples

<!-- Align self examples -->
<div class="flex items-start gap-4 p-4 bg-gray-light h-24">
  <div class="p-2 bg-blue text-white">Start</div>
  <div class="p-2 bg-green text-white self-center">Self Centered</div>
  <div class="p-2 bg-red text-white">End</div>
</div>

Gap

Control spacing between flex items.

Gap Properties

.gap-14pxgap: 4px;Small gap
.gap-28pxgap: 8px;Small gap
.gap-312pxgap: 12px;Medium gap
.gap-416pxgap: 16px;Standard gap
.gap-624pxgap: 24px;Large gap
.gap-832pxgap: 32px;Extra large gap

Examples

<!-- Gap examples -->
<div class="flex gap-2">
  <div class="p-2 bg-blue text-white">Item 1</div>
  <div class="p-2 bg-green text-white">Item 2</div>
  <div class="p-2 bg-red text-white">Item 3</div>
</div>

<div class="flex gap-6">
  <div class="p-4 bg-blue text-white">Item 1</div>
  <div class="p-4 bg-green text-white">Item 2</div>
  <div class="p-4 bg-red text-white">Item 3</div>
</div>

Common Layout Patterns

Header Layout

Header with Logo and Navigation

<header class="flex items-center justify-between p-6 bg-white border-b border-gray-light">
  <h1 class="text-2xl font-700">Logo</h1>
  <nav class="flex gap-6">
    <a href="#" class="text-base text-gray">
      Home
    </a>
    <a href="#" class="text-base text-gray">
      About
    </a>
    <a href="#" class="text-base text-gray">
      Contact
    </a>
  </nav>
</header>

Card Grid

Responsive Card Grid

<div class="flex flex-wrap gap-6">
  <div class="w-full md:w-1-2 lg:w-1-3">
    <div class="card p-6">
      <h3 class="text-xl font-600 mb-4">Card Title</h3>
      <p class="text-gray">Card content goes here.</p>
    </div>
  </div>
  <div class="w-full md:w-1-2 lg:w-1-3">
    <div class="card p-6">
      <h3 class="text-xl font-600 mb-4">Card Title</h3>
      <p class="text-gray">Card content goes here.</p>
    </div>
  </div>
  <div class="w-full md:w-1-2 lg:w-1-3">
    <div class="card p-6">
      <h3 class="text-xl font-600 mb-4">Card Title</h3>
      <p class="text-gray">Card content goes here.</p>
    </div>
  </div>
</div>

Centered Content

Centered Content Layout

<div class="flex items-center justify-center min-h-screen">
  <div class="max-w-md p-8 text-center">
    <h1 class="text-4xl font-700 mb-4">Welcome</h1>
    <p class="text-lg text-gray leading-relaxed mb-8">Your content here...</p>
    <button class="btn btn-blue">Get Started</button>
  </div>
</div>

Sidebar with Main Content

<div class="flex gap-6">
  <aside class="w-64 p-6 bg-gray-light">
    <h2 class="text-lg font-600 mb-4">Sidebar</h2>
    <nav class="flex flex-col gap-2">
      <a href="#" class="text-base text-gray">
        Link 1
      </a>
      <a href="#" class="text-base text-gray">
        Link 2
      </a>
      <a href="#" class="text-base text-gray">
        Link 3
      </a>
    </nav>
  </aside>
  <main class="flex-1 p-6">
    <h1 class="text-3xl font-700 mb-6">Main Content</h1>
    <p class="text-base leading-relaxed">Your main content goes here.</p>
  </main>
</div>

Best Practices

Flexbox Layouts

1

Use Semantic HTML

Always use proper HTML elements with flexbox utilities.
2

Consistent Gaps

Use the gap utility instead of margin for spacing between flex items.
3

Responsive Design

Consider how layouts will work on different screen sizes.
4

Accessibility

Ensure flexbox layouts work with screen readers and keyboard navigation.

Performance

  • Flexbox is well-optimized in modern browsers
  • Use gap instead of margin for better performance
  • Avoid deeply nested flexbox containers when possible