tailwindcss/packages
Jordan Pittman af15e1bdc0
Add support for important in v4 (#14448)
This PR allows modifying utility output by wrapping all utility
declarations in a custom selector or marking all utility declarations as
`!important`. This is the v4 equivalent to the `important` option in the
`tailwind.config.js` file.

## Mark all utility declarations as `!important`

To add `!important` to all utility declarations, you add an `important`
flag after the `@import` statement for `tailwindcss` or
`tailwindcss/utilities`:

```css
/** Importing `tailwindcss` */
@import "tailwindcss" important;

/** Importing the utilities directly */
@import "tailwindcss/utilities" important;
```

Example utility output:

```css
.mx-auto {
  margin-left: auto !important;
  margin-right: auto !important;
}

.text-center {
  text-align: center !important;
}
```

This is equivalent to adding `important: true` to the
`tailwind.config.js` file — which is still supported for backwards
compatibility.

## Wrap all utility declarations in a custom selector

To nest all utilities in an `#app` selector you add `selector(#app)`
flag after the `@import` statement for `tailwindcss` or
`tailwindcss/utilities`:

```css
/** Importing `tailwindcss` */
@import "tailwindcss" selector(#app);

/** Importing the utilities directly */
@import "tailwindcss/utilities" selector(#app);
```

Example utility output:

```css
.mx-auto {
  #app & {
    margin-left: auto;
    margin-right: auto;
  }
}

.text-center {
  #app & {
    text-align: center;
  }
}
```

This is equivalent to adding `important: "#app"` to the
`tailwind.config.js` file — which is still supported for backwards
compatibility.

**This _does not_ bring back support for the `respectImportant` flag in
`addUtilities` / `matchUtilities`.**
2024-10-03 16:25:11 +02:00
..
@tailwindcss-cli Improve @tailwindcss/postcss performance for initial builds (#14565) 2024-10-03 16:21:54 +02:00
@tailwindcss-node Improve @tailwindcss/postcss performance for initial builds (#14565) 2024-10-03 16:21:54 +02:00
@tailwindcss-postcss Improve @tailwindcss/postcss performance for initial builds (#14565) 2024-10-03 16:21:54 +02:00
@tailwindcss-standalone Update @types/bun 1.1.8 → 1.1.10 (patch) (#14542) 2024-09-28 11:20:51 +00:00
@tailwindcss-upgrade Migrate at-apply utilites with template migrations (#14574) 2024-10-03 09:35:28 -04:00
@tailwindcss-vite Improve @tailwindcss/postcss performance for initial builds (#14565) 2024-10-03 16:21:54 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Add support for important in v4 (#14448) 2024-10-03 16:25:11 +02:00
tsconfig.base.json introduce v4 codebase 2024-03-05 14:29:15 +01:00