Skip to content

docs: list where the CSS bundler adds color fallbacks - #45555

Open
robobun wants to merge 2 commits into
mainfrom
robobun/9f83adf3/css-color-fallback-docs
Open

robobun wants to merge 2 commits into
mainfrom
robobun/9f83adf3/css-color-fallback-docs

Conversation

@robobun

@robobun robobun commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • docs/bundler/css.mdx (lines 167, 197) promises RGB fallbacks for lab(), oklch() and color() colors with no exception. bun build adds them to some properties only, and never inside @keyframes.
  • Repro: .e{fill:lab(50% 40 59)} and @keyframes k{from{color:lab(50% 40 59)}} print lab(50% 40 59) alone. .a{color:lab(50% 40 59)} prints #bf5702, a display-p3 color, then lab(50% 40 59).
  • Cause: only BackgroundHandler, BorderHandler, BoxShadowHandler and FallbackHandler (color, text-shadow) add color fallbacks. src/css/properties/prefix_handler.rs:12 and src/css/rules/mod.rs:507 mark the rest as not implemented.

Fix

  • Docs only. The new section "Where Bun adds color fallbacks" lists the properties that get fallbacks and the places that get none (other properties, @keyframes, custom properties).
  • It shows what to write there: an RGB declaration before the lab() declaration, or one @supports rule for custom properties.
  • Verified on bun 1.4.3 and a debug build of main (5866b5f): both snippets build to their input, and each listed name behaves as stated (Notes).

Background

Notes

What ran (debug build of main 5866b5f, default targets)

  • Properties that get the RGB and display-p3 fallbacks for lab(50% 40 59), 31 of 31 rows: color, background (color and gradient), background-color, background-image, border, border-color, the four side shorthands and four side colors, the six logical shorthands and six logical colors, border-image, border-image-source, box-shadow, text-shadow. The 12 names that the section lists also ran with oklch(65% 0.25 10deg), lch(50% 70 40), oklab(65% 0.2 0.1) and color(display-p3 1 0.1 0.3).
  • Properties that stay as written, 25 of 25 rows: outline, outline-color, text-decoration, text-decoration-color, text-emphasis, text-emphasis-color, caret-color, accent-color, fill, stroke, column-rule, column-rule-color, scrollbar-color, filter, backdrop-filter, mask, mask-image, list-style-image, flood-color, lighting-color, stop-color, three -webkit- color properties, and a custom property.
  • @keyframes: 0 of 56 rows get a fallback, the 31 handled rows included.
  • Style rules inside @media, @supports, @layer, @container, @scope, @starting-style and nested rules get the fallbacks. @page, @property and @font-palette-values stay as written.
  • A hand-written pair (prop: #bf5702; prop: lab(50% 40 59)) stays a pair, in order, for 24 of 24 unhandled properties in style rules and for 31 of 31 properties in @keyframes, with and without --minify.
  • The two new snippets build to their input (after the /* file */ header line) on main and on bun 1.4.3. With --minify both declarations stay, in order.
  • :root{--accent:lab(50% 40 59)} .button{color:var(--accent)} gets no fallback.

Left out of the section

Related

The CSS page says that Bun adds RGB fallbacks for lab(), oklch() and
color() colors, with no exception. Bun adds them to color, the
background and border properties, box-shadow and text-shadow in style
rules. Other properties, @Keyframes and custom properties get none.

The new section lists both groups. It shows what to write in the
places that get no fallback: an RGB declaration before the declaration
with the newer color, or an @supports rule for a custom property.
@robobun

robobun commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Status: docs change is ready for review. No code change.

Reproduction: bun build ./in.css --minify --outdir out with bun 1.4.3 and with a debug build of main (5866b5f), on this input:

.a { color: lab(50% 40 59) }
.b { outline-color: lab(50% 40 59) }
.c { text-decoration-color: lab(50% 40 59) }
.d { caret-color: lab(50% 40 59) }
.e { fill: lab(50% 40 59) }
@keyframes k { from { color: lab(50% 40 59) } }

Only .a gets the RGB and display-p3 fallbacks. The other five rules print lab(50% 40 59) alone (250 bytes of output). The new docs section states this limit: #45555.

@robobun

robobun commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 11:41 AM PT - Oct 16th, 2026

✅ @robobun, your commit 30a6ec09e4c15bc1978bb41271e89e8785f56aa3 passed in Build #126761! 🎉


🧪   To try this PR locally:

bunx bun-pr 45555

That installs a local version of the PR into your bun-45555 executable, so you can run:

bun-45555 --bun

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: oven-sh/bun/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b278b847-ef43-4f02-a3f3-8da4ef3a75d5
📥 Commits

Reviewing files that changed from the base of the PR and between 5866b5f and 1dfa2ee.

📒 Files selected for processing: 1
  • docs/bundler/css.mdx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The CSS bundler documentation now describes where Bun adds color fallbacks, the LAB-family channel format required for generation, and cases that receive no automatic fallback. It includes examples for ordered RGB declarations and an @supports override for custom properties.

Changes

CSS color fallback documentation

Layer / File(s) Summary
Document color fallback coverage
docs/bundler/css.mdx
The LAB colors section links to guidance on fallback coverage. The guidance lists supported properties, LAB-family channel requirements, locations without automatic fallbacks, and fallback examples.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 1dfa2

This is a documentation-only clarification of where the CSS bundler adds color fallbacks. It does not change runtime behavior, and no merge-blocking risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main documentation change: identifying where the CSS bundler adds color fallbacks.
Description check Passed The description explains the problem, documents the fix, and provides detailed verification results. It does not use the template headings exactly, but it includes the required information under equiv…
Full details: Description check

Explanation

The description explains the problem, documents the fix, and provides detailed verification results. It does not use the template headings exactly, but it includes the required information under equivalent sections.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline finding on the @ supports pattern, I checked the new section's factual claims against the implementation: the handled-property list matches FallbackHandler in src/css/properties/prefix_handler.rs (only color and text-shadow, with fill/stroke/caret-color commented out) plus the background, border, border-image and box-shadow handlers, and the "no fallback inside @ keyframes" claim matches the unimplemented keyframes arm in src/css/rules/mod.rs. The lightness-as-percentage requirement and the voice rules (short sentences, active voice, "you") also hold up.

Extended reasoning...

Docs-only change adding a 50-line subsection to docs/bundler/css.mdx that enumerates which CSS properties receive lab/lch/oklab/oklch and color() fallbacks and recommends two workarounds. It touches no runtime code and no security-sensitive surface. The property list and the @ keyframes and custom-property claims were verified against src/css/properties/prefix_handler.rs and src/css/rules/mod.rs and are accurate; the one confirmed inline finding concerns the recommended @ supports workaround interacting with the always-on duplicate-condition drop at src/css/rules/mod.rs:529-534, which a human should weigh before merging.

Comment thread docs/bundler/css.mdx Resolved
The example now holds two selectors in one @supports rule, and the
sentence before it says to use one rule.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

LGTM. The single @ supports block in the second snippet (commit 30a6ec0) addresses the duplicate-condition drop I raised on the earlier push.

Checked the new section's claims against main: box-shadow has its own handler (src/css/properties/box_shadow.rs:180) and color/text-shadow are the only FallbackHandler fields (src/css/properties/prefix_handler.rs:10-18); @ keyframes falls through the minify pass with no fallback step (src/css/rules/mod.rs:506-510); parse_lab/parse_lch require percentage lightness and numeric a/b/c (src/css/values/color.rs:1338-1340, 1364-1365), so the "write oklch(65% 0.25 10)" guidance matches the parser. Fences are balanced and the #where-bun-adds-color-fallbacks anchor matches the heading slug.

Extended reasoning...

Docs-only change of about 58 lines in docs/bundler/css.mdx adding a "Where Bun adds color fallbacks" subsection and one cross-link; no code, no security-sensitive surface, and no CODEOWNERS entry covers docs/. The behavioral claims were verified against the CSS property handlers, the keyframes arm of the rule minifier, and the lab/lch parsers on main, and the prior-push concern about adjacent duplicate @ supports blocks is resolved by the current snippet. The one remaining inline finding is a pre-existing minifier limitation that the snippet does not trigger as written, not an error in the documentation.

Comment thread docs/bundler/css.mdx Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants