Display
Block
Use .block
to create a block-level element.
<div class="bg-gray-200 p-4">
<span class="block text-gray-700 text-center bg-gray-400 px-4 py-2">1</span>
<span class="block text-gray-700 text-center bg-gray-400 px-4 py-2 mt-2">2</span>
<span class="block text-gray-700 text-center bg-gray-400 px-4 py-2 mt-2">3</span>
</div>
Flow-Root
Use .flow-root
to create a block-level element with its own block formatting context.
<div class="flow-root bg-gray-400">
<div class="my-4 block text-gray-700 text-center bg-gray-500 px-4 py-2">1</div>
</div>
<div class="flow-root bg-gray-200">
<div class="my-4 block text-gray-700 text-center bg-gray-400 px-4 py-2">2</div>
</div>
Inline Block
Use .inline-block
to create an inline block-level element.
<div class="bg-gray-200">
<div class="inline-block text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">1</div>
<div class="inline-block text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">2</div>
<div class="inline-block text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">3</div>
</div>
Inline
Use .inline
to create an inline element.
<div class="bg-gray-200">
<div class="inline text-gray-700 text-center bg-gray-400 px-4 py-2">1</div>
<div class="inline text-gray-700 text-center bg-gray-400 px-4 py-2">2</div>
<div class="inline text-gray-700 text-center bg-gray-400 px-4 py-2">3</div>
</div>
Flex
Use .flex
to create a block-level flex container.
<div class="flex bg-gray-200">
<div class="flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">1</div>
<div class="flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">2</div>
<div class="flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">3</div>
</div>
Inline flex
Use .inline-flex
to create an inline flex container.
<div class="inline-flex bg-gray-200">
<div class="flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">1</div>
<div class="flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">2</div>
<div class="flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">3</div>
</div>
Grid
Use .grid
to create a grid container.
<div class="grid gap-4 grid-cols-3">
<!-- ... -->
</div>
Inline Grid
Use .inline-grid
to create an inline grid container.
<span class="inline-grid grid-cols-3 col-gap-4">
<span>1</span>
<span>1</span>
<span>1</span>
</span>
<span class="inline-grid grid-cols-3 col-gap-4">
<span>2</span>
<span>2</span>
<span>2</span>
</span>
Table
Use the .table
, .table-row
, .table-cell
, .table-caption
, .table-column
, .table-column-group
, .table-header-group
, table-row-group
, and .table-footer-group
utilities to create elements that behave like their respective table elements.
<div class="table w-full">
<div class="table-row-group">
<div class="table-row">
<div class="table-cell bg-gray-400 text-gray-700 px-4 py-2 text-sm">A cell with more content</div>
<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">Cell 2</div>
<div class="table-cell bg-gray-400 text-gray-700 px-4 py-2 text-sm">Cell 3</div>
</div>
<div class="table-row">
<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">Cell 4</div>
<div class="table-cell bg-gray-400 text-gray-700 px-4 py-2 text-sm">A cell with more content</div>
<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">Cell 6</div>
</div>
</div>
</div>
Hidden
Use .hidden
to set an element to display: none
and remove it from the page layout (compare with .invisible
from the visibility documentation).
<div class="flex bg-gray-200">
<div class="hidden text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">1</div>
<div class="text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">2</div>
<div class="text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">3</div>
</div>
Responsive
To control the display property of an element at a specific breakpoint, add a {screen}:
prefix to any existing display utility class. For example, use md:inline-flex
to apply the inline-flex
utility at only medium screen sizes and above.
For more information about Tailwind's responsive design features, check out the Responsive Design documentation.
<div class="flex sm:inline-flex md:block lg:hidden xl:flex ...">
<!-- ... -->
</div>
Customizing
Responsive and pseudo-class variants
By default, only responsive variants are generated for display utilities.
You can control which variants are generated for the display utilities by modifying the display
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- display: ['responsive'],
+ display: ['responsive', 'hover', 'focus'],
}
}
Disabling
If you don't plan to use the display utilities in your project, you can disable them entirely by setting the display
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ display: false,
}
}