Skip to content

Add support for @position-try at-rule#1238

Merged
devongovett merged 1 commit into
parcel-bundler:masterfrom
mattcosta7:add-position-try-rule
May 17, 2026
Merged

Add support for @position-try at-rule#1238
devongovett merged 1 commit into
parcel-bundler:masterfrom
mattcosta7:add-position-try-rule

Conversation

@mattcosta7

@mattcosta7 mattcosta7 commented May 8, 2026

Copy link
Copy Markdown
Contributor

Adds parsing and serialization support for the CSS Anchor Positioning @position-try at-rule.

Previously, stylesheets containing @position-try produced an Unknown at rule error.

Changes

  • New PositionTryRule in src/rules/position_try.rs containing a DashedIdent name and a DeclarationBlock.
  • Wired into the CssRule enum, ToCss impl, serde deserialization, and unused_symbols minification handling in src/rules/mod.rs.
  • Parser support via a new AtRulePrelude::PositionTry variant in src/parser.rs.
  • Added "position-try" mapping in napi/src/transformer.rs.
  • Tests in src/lib.rs covering minified output, pretty-printed output, and nesting inside @supports.

Fixes #858.

Adds parsing and serialization for the CSS Anchor Positioning @position-try at-rule.
@mattcosta7 mattcosta7 mentioned this pull request May 8, 2026

@devongovett devongovett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@devongovett devongovett merged commit c34e9ea into parcel-bundler:master May 17, 2026
RobinMalfait added a commit to tailwindlabs/tailwindcss that referenced this pull request Jun 25, 2026
This PR ignores Lightning CSS warnings for the unknow at-rule
`@position-try`.

This is a temporary fix/workaround until support for `@position-try`
lands in Lightning CSS:
parcel-bundler/lightningcss#1238

Fixes: #20275

## Test plan

Ran a test based on the issue:

Before:
```shellsession
❯ tw -i x.css -o out.css --optimize
≈ tailwindcss v4.3.1

Found 1 warning while optimizing generated CSS:

│   position-try-fallbacks: --flip-above;
│ }
│ @position-try --flip-above {
┆              ^-- Unknown at rule: @position-try
┆
│   top: auto;
│   bottom: 0;

Done in 29ms
```

After:
```shellsession
❯ tw -i x.css -o out.css --optimize
≈ tailwindcss v4.3.1

Done in 14ms
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support @position-try

2 participants