498 Commits
Author SHA1 Message Date
Jordan PittmanandGitHub 042242ad31 v3: Don’t break sibling-*() functions when used inside calc(…) (#19335)
The implementation of v3's math operator normalization uses a safe-list
of function names. Need to add `sibling-index()` and `sibling-count()`
to this list otherwise when used inside math functions like `calc()`
they'll get spaces around the `-`.
2025-11-19 10:35:48 -05:00
Jordan PittmanandGitHub 8796b383c4 v3: Remove irrelevant utility rules when matching important classes (#19030)
Fixes #18678

When given a simple plugin like this:
```js
export default {
  content: [{ raw: '!a' },],
  plugins: [
    ({ addBase }) => addBase({
      '@media (min-width: 1728px)': {
        '.a': { 'padding-top': '1rem !important' },
        '.b': { 'padding-right': '1rem !important' },
      }
    }),
  ],
}
```

If this plugin saw the utility `!a` it would correctly modify both rules
to eliminate any irrelevant classes. Unfortunately, in the case of the
2nd rule this meant it's left with an empty selector which is invalid.

We now detect this case and remove the rule if that happens.
2025-09-29 18:11:09 -04:00
2a2a4dd8ec v3: Allow hyphen character in regex pattern to use support queries as is (#13605)
This is the v3 equivalent of PR #13596

Matching for the hyphen character in the existing regex to use support
queries as-is

Resolves #13594

Tests (w/ updated):
- ✅ `supports-[display:grid]:grid`
- ✅ `supports-[transform-origin:5%_5%]:underline`
- ✅ `supports-[not(foo:bar)]:underline`
- ✅ `supports-[(foo:bar)or(bar:baz)]:underline`
- ✅ `supports-[(foo:bar)and(bar:baz)]:underline`
- ✅ `supports-[(foo:bar)_and_(bar:baz)]:grid`
- ✅ `supports-[(foo:bar)_and_(bar:baz)_or(baz:qux)]:grid`
- ✅ `supports-[container-type]:underline`
- ✅ `supports-grid:underline`
- ✅ `supports-[--test]:flex`
- ✅ `supports-[selector(A_>_B)]:underline`
- ✅ `supports-[font-format(opentype)]:grid`
- ✅ `supports-[font-tech(color-COLRv1)]:flex`

---------

Co-authored-by: Robin Malfait <[email protected]>
2025-01-28 17:42:09 +01:00
1d568ce1a5 Add variable fallback to fix Chrome issue (#15003)
This works around an issue in Chrome where `::selection` does not read
from variables defined on `::selection` thus breaking all uses of color
utilities with the selection variant. e.g. `selection::bg-red-200`.

We now add a fallback value of `1` to all uses of
`var(--tw-bg-opacity)`, `var(--tw-text-opacity)`,
`var(--tw-border-opacity)`, etc… since Chrome treats the variable as if
it did not exist because it's not defined on the parent.

In Chrome 131 (until the change is rolled back) existing utilities like
these will not work:
- `selection:text-opacity-50`
- `selection:[--tw-text-opacity:0.5]`

Fixes #15000

---------

Co-authored-by: Adam Wathan <[email protected]>
2024-11-14 13:33:27 -05:00
1f212b480f Insert @defaults at start of stylesheet (#14427)
Prior to this PR, we'd put all of the `@defaults` (the CSS variables and
stuff) _after_ the `base` rules. This creates an issue when using
`optimizeUniversalDefaults` with CSS that looks like this:

```css
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  input {
    @apply shadow;
  }
}
```

…because the default shadow stuff ends up after the base `input` rules,
so the generated styles are like this:

```css
input {
  --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color),
    0 1px 2px -1px var(--tw-shadow-color);
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
    var(--tw-shadow);
}

input {
  --tw-ring-offset-shadow: 0 0 #0000;
  --tw-ring-shadow: 0 0 #0000;
  --tw-shadow: 0 0 #0000;
  --tw-shadow-colored: 0 0 #0000;
}
```

This means all of the actual shadow values for the input are reset and
the shadow doesn't work.

Fixes https://github.com/tailwindlabs/tailwindcss/issues/14426.

Lots of failing tests right because this changes a ton of stuff, albeit
in a totally inconsequential way. @thecrypticace if you could update
these for me this week that would be a huge help, just banging this fix
out quick while the kids are napping 😴

---------

Co-authored-by: Adam Wathan <[email protected]>
Co-authored-by: Jordan Pittman <[email protected]>
2024-09-17 09:09:08 -04:00
Robin MalfaitandGitHub 7d22608d0d Allow anchor-size(…) in arbitrary values (#14393)
This PR fixes an issue where using `anchor-size` in arbitrary values
resulted in the incorrect css.

Input: `w-[calc(anchor-size(width)+8px)]`
Output:
```css
.w-\[calc\(anchor-size\(width\)\+8px\)\] {
  width: calc(anchor - size(width) + 8px);
}
```

This PR fixes that, by generating the correct CSS:
```css
.w-\[calc\(anchor-size\(width\)\+8px\)\] {
  width: calc(anchor-size(width) + 8px);
}
```
2024-09-11 19:23:53 +02:00
002080a137 Normalize attribute selector for data-* and aria-* modifiers (#14037)
Fixes #14026 
See #14040 for the v4 fix

When translating `data-` and `aria-` modifiers with attribute selectors,
we currently do not wrap the target attribute in quotes. This only works
for keywords (purely alphabetic words) but breaks as soon as there are
numbers or things like spaces in the attribute:

```html
<div data-id="foo" class="data-[id=foo]:underline">underlined</div>
<div data-id="f1" class="data-[id=1]:underline">not underlined</div>
<div data-id="foo bar" class="data-[id=foo_bar]:underline">not underlined</div>
```

Since it's fairly common to have attribute selectors with `data-` and
`aria-` modifiers, this PR will now wrap the attribute in quotes unless
these are already wrapped.

| Tailwind Modifier  | CSS Selector |
| ------------- | ------------- |
| `.data-[id=foo]`  | `[data-id='foo']`  |
| `.data-[id='foo']`  | `[data-id='foo']`  |
| `.data-[id=foo_i]`  | `[data-id='foo i']`  |
| `.data-[id='foo'_i]`  | `[data-id='foo' i]`  |
| `.data-[id=123]`  | `[data-id='123']`  |

---------

Co-authored-by: Robin Malfait <[email protected]>
2024-07-24 18:46:21 +02:00
Jordan PittmanandGitHub e48da0b303 Fix class detection in Slim templates with attached attributes and IDs (#14019)
* Fix class detection in Slim templates with attached attributes and IDs

* Update changelog

* Tweak regex
2024-07-18 11:21:20 -04:00
Josh WilsonandGitHub 79e73b8e02 Loosen :is() wrapping rules in applyImportantSelector for more readable output. (#13900) 2024-07-16 10:51:45 -04:00
Georg LedermannandGitHub 43ba84f829 Fix extracting utilities from slim/pug templates (#14006)
A class name starting with number like `2xl:bg-red-500` must not be removed.

Resolves #14005
2024-07-16 09:34:20 -04:00
81dd6a94c2 Always generate -webkit-backdrop-filter property (#13997)
* Always generate -webkit-backdrop-filter property

* Update changelog

---------

Co-authored-by: Adam Wathan <[email protected]>
2024-07-12 20:48:08 -04:00
4363637c0a Avoid over-extracting utilities from candidates with decimal values (#13959)
* Avoid over-extracting utilities from candidates with decimal values

Prevent candidates like `px-1.5` from generating both the `px-1.5` class and the `px-1` class.

* Update CHANGELOG.md

---------

Co-authored-by: Adam Wathan <[email protected]>
2024-07-05 14:46:51 -04:00
Robin MalfaitandGitHub a719bc4610 Use no value instead of blur(0px) for backdrop-blur-none and blur-none utilities (#13830)
* map `backdrop-blur-none` and `blur-none` to ` ` instead of `blur(0px)`

* add test for `backdrop-blur-none` and `blur-none`

* update changelog
2024-06-13 15:49:59 +02:00
Jordan PittmanandGitHub 1c811862d9 Disable automatic var() injection for anchor properties (#13826)
* Disable automatic `var()` injection for CSS anchor positioning properties

* Update tests

* Update changelog
2024-06-13 09:19:08 -04:00
Jordan PittmanandGitHub 4756634cb0 Bump deps (#13797) 2024-06-05 12:53:06 -04:00
Jordan PittmanandGitHub 408bb76953 [v3] Support negative values for {col,row}-{start,end} utilities (#13781)
* Support negative values for `{col,row}-{start,end}` utilities

* Add tests

* Update changelog
2024-06-03 11:34:27 -04:00
51d1e7e93e Don't prefix classes in arbitrary values of has-*, group-has-*, and peer-has-* variants (#13770)
* Added tests to verify that classes are prefixed when using `has-*` variants with arbitrary values

* Fix test

* Don't prefix classes in arbitrary values in `has-*` variants

* Update changelog

---------

Co-authored-by: Jordan Pittman <[email protected]>
2024-05-31 20:01:09 -04:00
f96f32656e Fix multiple <alpha-value> in color definitions (#13740)
* Fix multiple <alpha-value> in color definitions

Fixes #13716

* Update CHANGELOG.md

* Use `replace` with global regex

---------

Co-authored-by: Jordan Pittman <[email protected]>
2024-05-29 11:32:48 -04:00
Jordan PittmanandGitHub eb8d7dd491 Change dark selector so @apply works correctly with pseudo elements (#13379)
* Change dark selector so `@apply` hoists pseudo elements properly

* Update tests

* Update changelog
2024-03-27 11:03:49 -04:00
Robin MalfaitandGitHub a8151484e4 Ensure that arbitrary properties respect important configuration (#13353)
* ensure we respect important on arbitrary properties

* update changelog

* reword changelog entry
2024-03-26 11:42:41 +01:00
Robin MalfaitandGitHub 3c39beb16e Only detect nesting when using @apply (#13325)
* drop nesting detection for `@tailwind`

* drop separate nesting detection entirely

* detect nesting only when using `@apply` with a class that uses nesting

* drop unnecessary `important` config

* add test to verify applying nested user CSS errors

* add error reason to tests

* update `@apply` error message
2024-03-23 19:10:51 -04:00
a2cf3e7032 Reset letter spacing for form elements (#13150)
* Reset letter spacing for form elements

Some browsers, such as Chrome, set `letter-spacing: normal` for form elements. For consistency with the other styles, it should be set to `inherit` by Preflight.

* wip

* Update changelog

---------

Co-authored-by: Jordan Pittman <[email protected]>
2024-03-22 14:49:22 -04:00
Robin MalfaitGitHubdepfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
8bb7c599dd Cleanup oxide — Part #2 (#13312)
* remove all oxide related code

* Update lightningcss to version 1.24.1

* update tests to match bumped Lightning CSS output

---------

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
2024-03-22 17:12:14 +01:00
Robin MalfaitandGitHub d4b2cbb02a Cleanup oxide — Part #1 (#13304)
* swap engines

* remove all oxide related files

* drop swap engine step from CI

* drop oxide tests where we read from a `.oxide.*` file

* drop swap-engines.js file

* drop unused `oxide` variable

Let's make eslint happy!
2024-03-21 18:23:31 +01:00
Robin MalfaitandGitHub a5842a1820 Ensure dashes are allowed in variant modifiers (#13303)
* sync package-lock.json

* ensure dashes are allowed in variant modifiers

* update changelog
2024-03-21 15:25:28 +01:00
Kris BraunandAlexander 64ae6bb0c7 feat: add contain utilities (#12993)
* feat: add contain utilities

* chore: lint

* Support mulptiple contain properites

Support multiple contain properties, such as "contain-size contain-layout". Drop contain-unset as we haven't added -unset variants for other utilities.

* Update Vite; fix test regex

Vite is generating files like "index--T9oO-MP.css", which required relaxing the regex used in tests.

---------

Co-authored-by: Alexander <[email protected]>
2024-02-23 18:16:15 -05:00
17fdef7c97 Add mix-blend-plus-darker utility (#12923)
* feat: add plus-darker support for mix-blend-mode

* Fix failing test

* Update changelog

* Formatting

---------

Co-authored-by: Jonathan Reinink <[email protected]>
2024-02-23 16:37:32 -05:00
Jordan Pittman b403671246 Sort arbitrary properties alphabetically across multiple class lists (#12911)
* Sort arbitrary properties alphabetically across multiple files

* Update test
2024-02-13 14:17:23 -05:00
Jordan Pittman 7795456050 Split :has rules when using experimental.optimizeUniversalDefaults (#12736)
* Split `:has` rules when using optimizeUniversalDefaults

* Update changelog
2024-01-09 15:10:58 -05:00
Jordan Pittman b1d1f6764c Fix code style 2024-01-05 15:23:38 -05:00
Jordan PittmanandAdam Wathan 701d95e2af Restore old behavior for class dark mode, add new selector and variant options for dark mode (#12717)
* Add dark mode variant option

* Tweak warning messages

* Add legacy dark mode option

* wip

* Use `class` for legacy behavior, `selector` for new behavior

* Add simplified failing apply/where test case

* Switch to `where` list, apply changes to `dir` variants

* Don’t let `:where`, `:is:`, or `:has` be attached to pseudo elements

* Updating tests...

* Finish updating tests

* Remove `variant` dark mode strategy

* Update types

* Update comments

* Update changelog

* Revert "Remove `variant` dark mode strategy"

This reverts commit 185250438ccb2f61ba876d4676823c1807891122.

* Add variant back to types

* wip

* Update comments

* Update tests

* Rename variable

* Update changelog

* Update changelog

* Update changelog

* Fix CS

---------

Co-authored-by: Adam Wathan <[email protected]>
2024-01-05 15:20:11 -05:00
Jordan Pittman e21addc497 Don't add spaces to gradients and grid track names when followed by calc() (#12704)
* Don’t break gradient functions when following `calc()`

* Don’t break CSS grid track names

* Update changelog
2024-01-03 13:05:06 -05:00
Jordan Pittman 0c573e0972 Don't remove keyframe stops when using important utilities (#12639)
* Don't remove keyframe stops when using important utilities

* Fix test

* fix linting
2023-12-21 12:20:14 -05:00
55939011f5 Improve relative precedence of rtl, ltr, forced-colors and dark variants (#12584)
* Reduce specificity of `rtl`, `ltr`, and `dark` variants

Reduce specificity of `rtl`, `ltr`, and `dark` variants (when using `darkMode: 'class'`) to make them the same as other variants. This also sorts the LTR/RTL and dark variants later in the variant plugin list to ensure that the reduced specificity doesn't cause them to start "losing" to other variants to keep things as backwards compatible as possible.

Resolves a long-standing issue where `darkMode: 'media'` and `darkMode: 'class'` had different specificity, which meant switching your dark mode strategy could break your site.

* Update changelog

---------

Co-authored-by: Adam Wathan <[email protected]>
2023-12-18 13:58:22 -05:00
Luke WarlowandJordan Pittman eca8389ab1 Move forced-colors variant after dark variant (#12582)
Also add test for the order of the forced-colors variant
2023-12-18 13:58:22 -05:00
b7e59fe18b Add * variant for targeting direct children (#12551)
* add `*` as child variant

* add `*` as allowed variant character

* update test to reflect Lightning CSS output

* add `childVariant` test

* Update changelog

---------

Co-authored-by: Adam Wathan <[email protected]>
Co-authored-by: Robin Malfait <[email protected]>
Co-authored-by: Gregor Kaczmarczyk <[email protected]>
2023-12-18 13:58:22 -05:00
Jordan Pittman f5ee885132 Disable tap highlights on iOS (#12299)
* Disable tap highlights on iOS

* Update changelog

* Update snapshots

* Update changelog
2023-12-18 13:58:22 -05:00
16278dd935 feat(preflight): simplify sans-serif font stack (#11748)
* feat(preflight): simplify sans-serif font stack

`-apple-system` and `BlinkMacSystemFont` were historically needed for
IE11 and chakra-based Edge (The one that wasn't chromium-based).

https://caniuse.com/font-family-system-ui has more details around it.

* further simplify `font-family`

* update tests

* update changelog

---------

Co-authored-by: Robin Malfait <[email protected]>
2023-12-18 13:58:22 -05:00
506950e6ba Extend opacity scale to include all steps of 5 (#11832)
* Extend opacity scale to include all steps of 5

* Update changelog

---------

Co-authored-by: Adam Wathan <[email protected]>
2023-12-18 13:57:52 -05:00
65c9b5e35a Add support for text-wrap property (#11320)
Update changelog

Co-authored-by: Adam Wathan <[email protected]>
2023-12-18 13:57:22 -05:00
8171f17408 Add has-* variants for :has(...) pseudo-class (#11318)
* Add `has-*` variants for `:has(...)` pseudo-class

* Update changelog

* Fix mistake in test

---------

Co-authored-by: Adam Wathan <[email protected]>
2023-12-18 13:57:08 -05:00
Jordan PittmanandAdam Wathan 133456fdb9 Add svh, lvh, and dvh values to default theme (#11317)
* Add svh, lvh, and dvh values to default theme

* Update changelog

---------

Co-authored-by: Adam Wathan <[email protected]>
2023-12-18 13:56:52 -05:00
Jordan Pittman 8c25ad2da8 Fix support for container query utilities with arbitrary values (#12534)
* Fix support for container query utilities with arbitrary values

* Update changelog
2023-12-05 12:27:48 -05:00
Jordan Pittman 10e349327c Fix candidate detection regex 2023-12-04 11:23:33 -05:00
bf6c68ec74 Improve candidate detection in minified JS arrays (without spaces) (#12396)
* add test to verify `["util1","util2"]` works

* update extractor regex, to reduce valid values in the arbitrary value part

Co-authored-by: Autom <[email protected]>

* add special case with deeply nested `[]`

* update changelog

* move oxide changelog itemsto the bottom

---------

Co-authored-by: Autom <[email protected]>
2023-12-04 10:38:43 -05:00
Jordan Pittman 089e672b17 Fix source maps of variant utilities that come from an @layer rule (#12508)
* Refactor

* Keep traversing sibling nodes

* Make sure the root node has a source location for the end

* Add source map test for at-rule variants

* Update changelog
2023-12-01 11:46:18 -05:00
Jordan Pittman 750058dec5 Fix generation of utilities that use slashes in arbitrary modifiers (#12515)
* Fix support for slashes in arbitrary modifiers

* Update changelog
2023-12-01 11:46:18 -05:00
Jordan Pittman 0eb3e5321c Don't crash when given applying a variant to a negated version of a simple utility (#12514)
* Don't crash when given applying a variant to a negated version of a simple utility

* Update changelog
2023-12-01 11:46:18 -05:00
TomandJordan Pittman 3442b85b64 Ensure configured font-feature-settings for mono are included in Preflight (#12342)
* Use the default font-feature-settings for mono

* Update changelog

* Update tests

---------

Co-authored-by: Jordan Pittman <[email protected]>
2023-11-02 11:01:17 -04:00
Jordan Pittman 28fc176b8d Don’t add spaces to negative numbers following a comma (#12324)
* Don’t add spaces to negative numbers following a comma

* Update changelog
2023-10-30 14:45:46 -04:00