No description
Find a file
Robin Malfait de48a76b6d
Ensure opacity modifier with variables work with color-mix() (#13972)
* ensure opacity modifier variables work as expected

We use `color-mix()` in v4 which means that we can use this for the
opacity modifier. One thing we do already is convert values such as
`0.5` to `50%` because that's what the `color-mix()` function expects.

However, if you use a variable like this:

```html
<div class="[--opacity:0.5] bg-red-500/[var(--opacity)]"></div>
```

This currently generates:

```css
.bg-red-500\/\[var\(--opacity\)\] {
  background-color: color-mix(
    in srgb,
    var(--color-red-500, #ef4444) var(--opacity),
    transparent
  );
}
.\[--opacity\:0\.5\] {
  --opacity: 0.5;
}
```

Which won't work because the opacity variable resolves to `0.5` instead
of the expected`50%`.

This commit fixes that by always ensuring that we use `* 100%`.

- If you already had a percentage, we would have `calc(50% * 100%)`
  which is `50%`.
- If we have `0.5` then we would have `calc(0.5 * 100%)` which is also
  `50%`.

* wrap everything but percentages in `calc(… * 100%)`

* use `else if`

* update changelog
2024-07-10 15:52:05 +02:00
.github Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
crates Prep next release: 4.0.0-alpha.17 (#13951) 2024-07-04 19:08:10 +02:00
packages Ensure opacity modifier with variables work with color-mix() (#13972) 2024-07-10 15:52:05 +02:00
playgrounds Bump dependencies (#13741) 2024-05-25 14:43:59 +02:00
scripts Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
.gitignore Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
.npmrc introduce v4 codebase 2024-03-05 14:29:15 +01:00
.prettierignore Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
Cargo.lock remove Rust benchmarks and fixtures (#13335) 2024-03-23 16:16:40 +01:00
Cargo.toml Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
CHANGELOG.md Ensure opacity modifier with variables work with color-mix() (#13972) 2024-07-10 15:52:05 +02:00
LICENSE Add README, LICENSE, and CONTRIBUTING (#13088) 2024-03-05 14:45:39 -05:00
package.json Bump dependencies (#13738) 2024-05-24 15:07:44 +02:00
pnpm-lock.yaml Bump dependencies (#13741) 2024-05-25 14:43:59 +02:00
pnpm-workspace.yaml Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
README.md Copy README file to every package (#13096) 2024-03-06 08:49:31 -05:00
turbo.json introduce v4 codebase 2024-03-05 14:29:15 +01:00
vitest.workspace.ts introduce v4 codebase 2024-03-05 14:29:15 +01:00

Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Tailwind CSS on GitHub

For chatting with others using the framework:

Join the Tailwind CSS Discord Server

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.