You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.7 KiB

2 years ago
  1. # tailwindcss/nesting
  2. This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
  3. Add it to your PostCSS configuration, somewhere before Tailwind itself:
  4. ```js
  5. // postcss.config.js
  6. module.exports = {
  7. plugins: [
  8. require('postcss-import'),
  9. require('tailwindcss/nesting'),
  10. require('tailwindcss'),
  11. require('autoprefixer'),
  12. ]
  13. }
  14. ```
  15. By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
  16. If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
  17. ```shell
  18. npm install postcss-nesting
  19. ```
  20. Then pass the plugin itself as an argument to `tailwindcss/nesting` in your PostCSS configuration:
  21. ```js
  22. // postcss.config.js
  23. module.exports = {
  24. plugins: [
  25. require('postcss-import'),
  26. require('tailwindcss/nesting')(require('postcss-nesting')),
  27. require('tailwindcss'),
  28. require('autoprefixer'),
  29. ]
  30. }
  31. ```
  32. This can also be helpful if for whatever reason you need to use a very specific version of `postcss-nested` and want to override the version we bundle with `tailwindcss/nesting` itself.