Skip to content

Commit 53b6c87

Browse files
authored
Document new blocklist feature (#1427)
Co-authored-by: Adam Wathan <[email protected]>
1 parent dc3cc81 commit 53b6c87

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/pages/docs/content-configuration.mdx

+36
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,42 @@ module.exports = {
383383
}
384384
```
385385

386+
### Discarding classes
387+
388+
Since Tailwind uses a very simple approach to detecting class names in your content, you may find that some classes are being generated that you don't actually need.
389+
390+
For example, this HTML would still generate the `container` class, even though that class is not actually being used:
391+
392+
```html
393+
<div class="text-lg leading-8 text-gray-600">
394+
Every custom pool we design starts as a used shipping **container**, and is
395+
retrofitted with state of the art technology and finishes to turn it into
396+
a beautiful and functional way to entertain your guests all summer long.
397+
</div>
398+
```
399+
400+
You may also want to prevent Tailwind from generating certain classes when those classes would conflict with some existing CSS, but you don't want to go so far as to prefix all of your Tailwind classes.
401+
402+
In these situations, you can use the `blocklist` option to tell Tailwind to ignore specific classes that it detects in your content:
403+
404+
```js tailwind.config.js
405+
module.exports = {
406+
content: [
407+
'./pages/**/*.{html,js}',
408+
'./components/**/*.{html,js}',
409+
],
410+
blocklist: [
411+
'container',
412+
'collapse',
413+
],
414+
// ...
415+
}
416+
```
417+
418+
The `blocklist` option only affects CSS that would be generated by Tailwind, not custom CSS you've authored yourself or are importing from another library.
419+
420+
Unlike `safelist`, the `blocklist` option only supports strings, and you cannot block classes using regular expressions.
421+
386422
---
387423

388424
## Transforming source files

0 commit comments

Comments
 (0)