tailwindcss/packages
Robin Malfait 4035ab0b76
Implement @variant (#15663)
This PR replaces `@variant` with `@custom-variant` for registering
custom variants via your CSS.

In addition, this PR introduces `@variant` that can be used in your CSS
to use a variant while writing custom CSS.

E.g.:

```css
.btn {
  background: white;

  @variant dark {
    background: black;
  }
}
```

Compiles to:

```css
.btn {
  background: white;
}

@media (prefers-color-scheme: dark) {
  .btn {
    background: black;
  }
}
```

For backwards compatibility, the `@variant` rules that don't have a body
and are
defined inline:

```css
@variant hocus (&:hover, &:focus);
```

And `@variant` rules that are defined with a body and a `@slot`:

```css
@variant hocus {
  &:hover, &:focus {
    @slot;
  }
}
```

Will automatically be upgraded to `@custom-variant` internally, so no
breaking changes are introduced with this PR.

---

TODO:
- [x] ~~Decide whether we want to allow multiple variants and if so,
what syntax should be used. If not, nesting `@variant <variant> {}` will
be the way to go.~~ Only a single `@variant <variant>` can be used, if
you want to use multiple, nesting should be used:

```css
.foo {
  @variant hover {
    @variant focus {
      color: red;
    }
  }
}
```
2025-01-21 10:20:35 -05:00
..
@tailwindcss-browser Update h3 1.13.0 → 1.13.1 (patch) (#15661) 2025-01-20 15:39:26 +01:00
@tailwindcss-cli Write to stdout when --output is omitted (#15656) 2025-01-17 15:23:34 +00:00
@tailwindcss-node Prepare v4.0.0-beta.9 release (#15583) 2025-01-09 17:04:34 +00:00
@tailwindcss-postcss Remove @property fallbacks for Firefox (#15622) 2025-01-14 15:51:44 +01:00
@tailwindcss-standalone Upgrade lightningcss to 1.29.1 in standalone package (#15641) 2025-01-16 16:06:08 +01:00
@tailwindcss-upgrade Implement @variant (#15663) 2025-01-21 10:20:35 -05:00
@tailwindcss-vite Prepare v4.0.0-beta.9 release (#15583) 2025-01-09 17:04:34 +00:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Implement @variant (#15663) 2025-01-21 10:20:35 -05:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00