Whitespace
Utilities for controlling an element’s white-space property.
Default class reference
| Class | Properties |
|---|---|
| whitespace-normal | white-space: normal; |
| whitespace-nowrap | white-space: nowrap; |
| whitespace-pre | white-space: pre; |
| whitespace-pre-line | white-space: pre-line; |
| whitespace-pre-wrap | white-space: pre-wrap; |
Normal
Use whitespace-normal to cause text to wrap normally within an element. Newlines and spaces will be collapsed.

1. <div class="w-3/4 ...">
2. <div class="whitespace-normal ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
3. eum natus enim maxime
4. laudantium quibusdam illo nihil,
6. reprehenderit saepe quam aliquid odio accusamus.</div>
7. </div>
No Wrap
Use whitespace-nowrap to prevent text from wrapping within an element. Newlines and spaces will be collapsed.

1. <div class="w-3/4 overflow-x-auto ...">
2. <div class="whitespace-nowrap ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
3. eum natus enim maxime
4. laudantium quibusdam illo nihil,
6. reprehenderit saepe quam aliquid odio accusamus.</div>
7. </div>
Pre
Use whitespace-pre to preserve newlines and spaces within an element. Text will not be wrapped.

1. <div class="w-3/4 overflow-x-auto ...">
2. <div class="whitespace-pre ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
3. eum natus enim maxime
4. laudantium quibusdam illo nihil,
6. reprehenderit saepe quam aliquid odio accusamus.</div>
7. </div>
Pre Line
Use whitespace-pre-line to preserve newlines but not spaces within an element. Text will be wrapped normally.

1. <div class="w-3/4 ...">
2. <div class="whitespace-pre-line ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
3. eum natus enim maxime
4. laudantium quibusdam illo nihil,
6. reprehenderit saepe quam aliquid odio accusamus.</div>
7. </div>
Pre Wrap
Use whitespace-pre-wrap to preserve newlines and spaces within an element. Text will be wrapped normally.

1. <div class="w-3/4 ...">
2. <div class="whitespace-pre-wrap ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
3. eum natus enim maxime
4. laudantium quibusdam illo nihil,
6. reprehenderit saepe quam aliquid odio accusamus.</div>
7. </div>
Responsive
To control the whitespace property of an element only at a specific breakpoint, add a {screen}: prefix to any existing whitespace utility. For example, adding the class md:whitespace-pre to an element would apply the whitespace-pre utility at medium screen sizes and above.
1. <div class="whitespace-normal md:whitespace-pre ...">
2. <!-- ... -->
3. </div>
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 whitespace utilities.
You can control which variants are generated for the whitespace utilities by modifying the whitespace property in the variants section of your tailwind.config.js file.
For example, this config will also generate hover and focus variants:
1. // tailwind.config.js
2. module.exports = {
3. variants: {
4. extend: {
5. // ...
6. + whitespace: ['hover', 'focus'],
7. }
8. }
9. }
Disabling
If you don’t plan to use the whitespace utilities in your project, you can disable them entirely by setting the whitespace property to false in the corePlugins section of your config file:
1. // tailwind.config.js
2. module.exports = {
3. corePlugins: {
4. // ...
5. + whitespace: false,
6. }
7. }
