Floats

Utilities for controlling the wrapping of content around an element.

Class reference

Class Properties
.float-right float: right;
.float-left float: left;
.float-none float: none;
.clearfix &::after {   content: "";   display: table;   clear: both; }

Float right

Use .float-right to float an element to the right of its container.

1
2
3
<div class="clearfix bg-gray-200 p-4">
  <div class="float-right text-gray-700 text-center bg-gray-400 px-4 py-2 ml-2">1</div>
  <div class="float-right text-gray-700 text-center bg-gray-400 px-4 py-2 ml-2">2</div>
  <div class="float-right text-gray-700 text-center bg-gray-400 px-4 py-2">3</div>
</div>

Float left

Use .float-left to float an element to the left of its container.

1
2
3
<div class="clearfix bg-gray-200 p-4">
  <div class="float-left text-gray-700 text-center bg-gray-400 px-4 py-2 mr-2">1</div>
  <div class="float-left text-gray-700 text-center bg-gray-400 px-4 py-2 mr-2">2</div>
  <div class="float-left text-gray-700 text-center bg-gray-400 px-4 py-2">3</div>
</div>

Don't float

Use .float-none to reset any floats that are applied to an element. This is the default value for the float property.

Clearfix

Use .clearfix to force an element to self-clear its children.

Without clearfix

1
2
3

With clearfix

1
2
3
<div class="bg-gray-200 p-4">
  <div class="float-left bg-gray-400 px-4 py-2 mr-2">1</div>
  <div class="float-left bg-gray-400 px-4 py-2 mr-2">2</div>
  <div class="float-left bg-gray-400 px-4 py-2">3</div>
</div>

<div class="clearfix bg-gray-200 p-4">
  <div class="float-left bg-gray-400 px-4 py-2 mr-2">1</div>
  <div class="float-left bg-gray-400 px-4 py-2 mr-2">2</div>
  <div class="float-left bg-gray-400 px-4 py-2">3</div>
</div>

Responsive

To control the float of an element at a specific breakpoint, add a {screen}: prefix to any existing float utility class. For example, use md:float-left to apply the float-left utility at only medium screen sizes and above.

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.

1
2
3
1
2
3
1
2
3
1
2
3
1
2
3

Customizing

Responsive and State Variants

By default, only responsive variants are generated for float utilities.

You can control which variants are generated for the float utilities by modifying the float 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: {
    // ...
-   float: ['responsive'],
+   float: ['responsive', 'hover', 'focus'],
}
}

Disabling

If you don't plan to use the float utilities in your project, you can disable them entirely by setting the float property to false in the corePlugins section of your config file:

// tailwind.config.js
module.exports = {
corePlugins: {
    // ...
+   float: false,
}
}