[v4] Inactive document tabs use the ghost button color on Next.js (no Lexical): the `.doc-tab` color depends on stylesheet order

Open
#19,406 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
design, frontend

Research direction

Read packages/ui/src/elements/DocumentHeader/Tabs/Tab/index.css, packages/ui/src/elements/Button/index.css, and packages/ui/bundle.js to trace how the competing rules enter the Next.js stylesheet. Reproduce with the linked Next.js setup without Lexical and inspect the computed color of an inactive tab. Done when inactive tabs use --color-text-secondary across the described bundler and stylesheet-order cases.

Written by the indexing model from the issue text.

Description

area: ui Bug created-by: Contributor status: needs-triage v3
Describe the Bug

On Next.js, inactive document tabs ("Versions", "API" next to the active "Edit") render in --color-text, so they look as strong as the active tab. On TanStack Start, the same tabs render in --color-text-secondary, as intended. The markup and classes are the same in both:

<a class="btn doc-tab btn--size-medium btn--withoutPopup btn--no-margin btn--style-ghost btn--withoutPopup" aria-current="false">

Two rules with equal specificity set the color, and both are in @layer payload-default:

So whichever stylesheet comes last wins. Here is the order on Next:

  1. RootLayout imports @payloadcms/ui/css/app.css (layouts/Root/index.tsx#L14).
  2. That file runs @import '../styles.css' (css/app.css#L3).
  3. dist/styles.css is built by bundle.js from the src/exports/client/index.ts graph only (bundle.js#L74-L104). It contains the Button CSS, ghost rule included. It does not contain DocumentHeader/Tabs/Tab/index.css, because the tabs aren't reachable from the client export. In 4.0.0-beta.7, 52 of the 334 component CSS files in dist/ are missing from styles.css.
  4. Turbopack emits the per-component CSS (Tab/index.css) before the layout's app.css → styles.css. So .btn--style-ghost comes after the last .doc-tab, and the tab turns --color-text.

TanStack Start links app.css first and the component CSS after it, so .doc-tab wins there.

Most apps don't see this, because @payloadcms/richtext-lexical loads field/bundled.css. That file has another full copy of the UI CSS, .doc-tab included, after the ghost rule. Apps without Lexical (or whose pages don't pull it in) get the dark tabs.

Measured on the edit view, dark theme. --color-text is #fff and --color-text-secondary is #ffffffb3.

App "Versions" / "API" color Last relevant rule in the sheet
Next dev, no Lexical (repro branch) rgb(255, 255, 255) .btn--style-ghost from ui/dist/styles.css
Next dev, with Lexical (repro baseline) rgba(255, 255, 255, 0.7) .doc-tab from richtext-lexical/dist/field/bundled.css
TanStack Start dev, no Lexical rgba(255, 255, 255, 0.7) .doc-tab from Tab/index.css (after app.css)

Next.js, no Lexical (bug):

Image

TanStack Start, same config (expected):

Image

Expected: inactive tabs are --color-text-secondary regardless of bundler, stylesheet order, or whether Lexical is installed.

Link to the code that reproduces this issue

https://github.com/VeiaG/payload-4-reproductions/tree/repro-doc-tab-color-css-order

Reproduction Steps

The only change from the baseline: the Lexical editor and the richText field on posts are removed, and the import maps are regenerated.

  1. pnpm install, then pnpm dev in apps/next.
  2. Open any post, e.g. create one and open its edit view.
  3. "Versions" and "API" are as bright as the active "Edit". In devtools, the winning color on the inactive tab is .btn--style-ghost from @payloadcms/ui/dist/styles.css, which overrides .doc-tab.
  4. Run apps/tanstack (pnpm dev) with the same config and open the same view. The inactive tabs are dimmed.
Which area(s) are affected?

area: ui

Environment Info
payload: 4.0.0-beta.7
@payloadcms/ui: 4.0.0-beta.7
@payloadcms/next: 4.0.0-beta.7
@payloadcms/tanstack-start: 4.0.0-beta.7
next: 16.4.4 (Turbopack, dev)
Node: 24
Browser: Chrome
Dominant language
TypeScript
Stars
45.8k
Forks
4.4k
Avg merge
2d 16h
Merged PRs (30d)
251

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from payloadcms/payload

All issues in payloadcms/payload

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.