Text Overflow
Utilities for controlling text overflow in an element.
Default class reference
Class | Properties |
---|---|
truncate | overflow: hidden; text-overflow: ellipsis; white-space: nowrap; |
overflow-ellipsis | text-overflow: ellipsis; |
overflow-clip | text-overflow: clip; |
Truncate
Use truncate
to truncate overflowing text with an ellipsis (…
) if needed.
<p class="truncate ...">...</p>
Overflow Ellipsis
Use overflow-ellipsis
to truncate overflowing text with an ellipsis (…
) if needed.
<p class="overflow-ellipsis overflow-hidden ...">...</p>
Overflow Clip
Use overflow-clip
to truncate the text at the limit of the content area.
<p class="overflow-clip overflow-hidden ...">...</p>
Responsive
To control the text overflow in an element only at a specific breakpoint, add a {screen}:
prefix to any existing text overflow utility. For example, adding the class md:overflow-clip
to an element would apply the overflow-clip
utility at medium screen sizes and above.
<p class="truncate md:overflow-clip ...">
<!-- ... -->
</p>
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
Customizing
Variants
By default, only responsive variants are generated for text overflow utilities.
You can control which variants are generated for the text overflow utilities by modifying the textOverflow
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: {
extend: {
// ...
+ textOverflow: ['hover', 'focus'],
}
}
}
Disabling
If you don’t plan to use the text overflow utilities in your project, you can disable them entirely by setting the textOverflow
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ textOverflow: false,
}
}