Skip to content

[SUR-397] [ForceUI] Migrate TailwindCSS v3.x.x to v4.x.x#470

Open
jaieds wants to merge 5 commits into
stagingfrom
fix/SUR-397-tailwindcss-v4-migration
Open

[SUR-397] [ForceUI] Migrate TailwindCSS v3.x.x to v4.x.x#470
jaieds wants to merge 5 commits into
stagingfrom
fix/SUR-397-tailwindcss-v4-migration

Conversation

@jaieds

@jaieds jaieds commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes brainstormforce/surerank#1830 (SUR-397)

Summary

Migrates @bsf/force-ui from TailwindCSS v3.4 to v4.3.2 as a CSS-first library, released as 2.0.0 (breaking).

  • withTW() is deprecated (kept as a legacy @config shim, removed in 3.0.0). The theme now ships as CSS: consumers @import "@bsf/force-ui/theme.css" and override tokens in their own @theme block.
  • src/theme/theme.css — all design tokens as @theme variables, the not-rtl variant as @custom-variant, and v3-parity hairline utilities (border-*-0.5, divide-x/y-0.5). No preflight — consumers keep control of the base layer.
  • PostCSS: tailwindcss + autoprefixer@tailwindcss/postcss; dropped @tailwindcss/container-queries (in core) and tailwindcss-scoped-preflight; deleted tailwind.config.js.
  • Template sweep per the upgrade guide: shadow-sm→shadow-xs, rounded→rounded-sm, outline-none→outline-hidden, bare shadow/rounded, and the important modifier moved from prefix to suffix (!xx!).
  • tailwind-merge ^2 → ^3 (v2 can drop v4 trailing-! classes when merging).
  • README: v2 migration guide, consumer upgrade checklist, WordPress/webpack integration notes, and a copy-pasteable Theme Tokens Reference (all 162 tokens).

Token parity was verified by compiling probes against the v3 output (byte-identical values), plus Storybook visual checks and full integration testing against SureRank/SureRank Pro.

Consumer impact (breaking)

Every consumer must update its CSS entry, PostCSS config, and drop v4-removed config keys (corePlugins, selector-string important, variants, safelist). The exact steps and gotchas are documented in the README's "Migrating to v2.0.0" section.

Test plan

  • npm run build green (dual ESM/CJS + dist/theme.css)
  • npm run lint:js / lint:css clean
  • npm run test — 234/234 passing
  • Storybook visual spot-checks (Button, Switch/not-rtl, Alert, tables)
  • End-to-end consumer verification in SureRank + SureRank Pro (wp-admin, front-end popup, Shadow DOM)

jaieds added 3 commits July 1, 2026 20:26
BREAKING CHANGE: @bsf/force-ui now targets Tailwind CSS v4, which is
CSS-first. The JS `withTW()` helper is deprecated in favor of a shipped
CSS theme, and consumers must update their CSS entry + PostCSS setup.

- Add src/theme/theme.css: @theme port of all design tokens + the
  `not-rtl` custom variant (@custom-variant) and a `border-0.5` utility.
  Spacing/size/leading/z-index/fraction-widths are omitted — v4's dynamic
  utility scale reproduces them at identical values (verified by compile).
- src/tailwind.css: @tailwind directives -> @import "tailwindcss" + theme.
- postcss.config.cjs: tailwindcss + autoprefixer -> @tailwindcss/postcss.
- package.json: v2.0.0; tailwindcss ^4.3.2; add @tailwindcss/postcss;
  drop @tailwindcss/container-queries, autoprefixer, tailwindcss-scoped-
  preflight; expose ./theme.css export.
- vite.config.ts: emit theme.css to dist on build.
- withTW.js: mark @deprecated (kept as legacy @config shim, removed in 3.0.0).
- Delete tailwind.config.js (v4 auto-detects sources; not auto-loaded).
- Rename renamed-in-v4 utilities across component/story source:
  shadow-sm->shadow-xs, outline-none->outline-hidden, rounded-sm->rounded-xs,
  bare rounded->rounded-sm, bare shadow->shadow-sm.
- README: add v2.0.0 migration guide (before/after + removed-keys table).

Refs #1830 / SUR-397
List every @theme token shipped in theme.css (162 tokens across colors,
shadows, font-size and letter-spacing), grouped by category in a
collapsible section, so developers can see exactly which variables to
override. Generated from src/theme/theme.css.

Refs #1830 / SUR-397
Issues found while migrating SureRank/SureRank Pro onto 2.0.0:

- theme.css: add per-side border-*-0.5 and divide-{x,y}-0.5 utilities
  (v3's borderWidth {0.5} theme key generated these variants; without
  them, border-style falls back to the browser 'medium' width because
  preflight is excluded).
- Move the v3 important prefix to the v4 suffix in remaining component
  and story classes (!x -> x!); v4 does not recognize the prefix form.
- Bump tailwind-merge to ^3 — v2 predates the v4 trailing-! syntax and
  can drop such classes when merging.
- README: add consumer upgrade checklist and WordPress/webpack notes
  (standalone PostCSS pass for the Tailwind entry, no @layer inside
  wp-admin, preflight-off border compat, space-* selector change).

Refs #1830 / SUR-397
@socket-security

socket-security Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedtailwindcss@​3.4.19 ⏵ 4.3.2100 +310081 -598100
Updatedpostcss@​8.5.8 ⏵ 8.5.16100 +1100 +281 -192100
Updatedtailwind-merge@​2.6.1 ⏵ 3.6.010010086 +195100
Added@​tailwindcss/​postcss@​4.3.29910010098100

View full report

Comment thread package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@bsf/force-ui",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What: Version upgrade from 1.7.13 to 2.0.0 is a breaking change. Ensure that all parts of the application that rely on this library handle the new version correctly.

Why: Breaking changes can lead to significant issues in dependent components if not properly managed. It is crucial to document any adjustments required.

How: To manage this, update the documentation to include migration steps, particularly highlighting the breaking changes introduced in this release.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job! ✅ The PR looks solid with no security or performance issues.

Please make sure to resolve any remaining comments if any. Approved 👍

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.

1 participant