Skip to content

chore(web): migrate to Tailwind CSS v4 - #86

Open
vianbas wants to merge 1 commit into
mainfrom
chore/tailwind-v4
Open

vianbas wants to merge 1 commit into
mainfrom
chore/tailwind-v4

Conversation

@vianbas

@vianbas vianbas commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

This migrates the web app from Tailwind CSS 3.4 to 4.3. Dependabot's #75 bumps the package but cannot migrate the configuration, so its build fails:

[postcss] It looks like you're trying to use tailwindcss directly as a PostCSS plugin…

This PR does the migration. Merging it makes #75 redundant, so #75 can be closed.

Closes #85

Architecture summary

  • Official upgrade tool: @tailwindcss/upgrade did most of the work, and I reviewed its output by hand.
    • postcss.config.js now uses @tailwindcss/postcss. autoprefixer is removed because v4 adds vendor prefixes itself.
    • In src/index.css, @tailwind base/components/utilities is replaced by @import "tailwindcss". tailwind.config.ts is replaced by CSS-first @theme tokens that map onto the existing shadcn hsl(var(--…)) variables, so :root and .dark are unchanged.
    • Dark mode keeps the class strategy via @custom-variant dark (&:is(.dark *)).
    • Two v4 renames: shadow-sm becomes shadow-xs (chart tooltip), and outline-none becomes outline-hidden (button).
  • Manual follow-ups the tool does not do:
    • The tool's default-border compatibility block is folded into the existing @apply border-border rule, now extended to pseudo-elements.
    • v3 parity in base styles: a pointer cursor on enabled buttons (v4 dropped it) and gray-400 placeholders (v4 uses currentColor at 50%).
    • Login labels are now block. In v4, space-y-* puts margin-bottom on every child except the last, and inline <label> elements ignore vertical margins. Without this change the label-to-input gap disappeared.
    • components.json no longer points at a Tailwind config file ("config": "").

Security considerations

Testing evidence

$ cd apps/web && npm run lint && npm run typecheck && npm test && npm run build
 Test Files  15 passed (15)
      Tests  95 passed (95)
✓ built in 479ms
$ git diff --check   # clean

Visual regression check. I captured screenshots in headless Chromium against the real API and a fixed synthetic database: Login, Dashboard, Alerts and Rules as admin, at 1280×900 and 390×844, plus the open mobile menu. I compared v3 (main) and v4 (this branch) pixel by pixel:

Page Differing pixels Cause
Alerts, Rules, mobile menu 60 px Only the 8×8 "Live" status dot. v4's default palette is OKLCH, so green-600 goes from rgb(22,163,74) to rgb(0,166,62).
Dashboard (desktop) 2,530 px The status dot, plus severity-table text shifted ≤1px (sub-pixel, not visible side by side).
Dashboard (mobile) 12,039 px The same, and the severity chart now renders. On v3 the chart was blank in both baseline captures when the page was opened through the mobile menu; on v4 it renders. I did not root-cause the v3 behaviour.
Login 8,489 px The form is about 8px shorter. On v3 the inline label sat in a line box that inherited the parent's 24px line height; as a block it uses text-sm's own 20px. The label-to-input gap is the same as before. The placeholder grey differs slightly (OKLCH palette).

There are no layout breaks, no missing borders and no changes to colour tokens. All shadcn token colours are identical.

Known limitations

  • Tailwind's default palette colours used directly (the status dot's green/yellow/red) shift slightly because v4 moved to OKLCH. App tokens are unaffected. To reproduce v3 exactly, those three colours could be pinned to hex.
  • Visual parity was checked in Chromium only.

Follow-up issues

  • None required.

Checklist

  • Branch is not main; this PR targets main.
  • Conventional commit messages.
  • Frontend quality gates pass locally (lint, typecheck, test, build). Backend is unchanged.
  • git diff --check is clean.
  • No secrets, real/personal data, or proprietary references.
  • Contracts updated first where applicable: not applicable, no API change.
  • Docs updated to match the change: not applicable; docs reference Tailwind without a version.

- tailwindcss 3.4 -> 4.3 via @tailwindcss/upgrade; the PostCSS plugin
  moves to @tailwindcss/postcss and autoprefixer is dropped (v4 handles
  vendor prefixes).
- tailwind.config.ts is replaced by CSS-first @theme tokens in
  src/index.css; the shadcn CSS variables and the .dark class variant
  are kept, and components.json no longer points at a config file.
- Renamed utilities: shadow-sm -> shadow-xs, outline-none ->
  outline-hidden.
- v3 parity in base styles: border-border on pseudo-elements, a pointer
  cursor on enabled buttons, and gray-400 placeholders.
- Login labels become block: v4's space-y-* puts margin-bottom on all
  but the last child, which inline labels ignore.

Closes #85

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xzt3HRqVzoHnEyEUbTT3h9
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T03:02:44.279466Z 024574a PR opened
🔒 Security Review ✅ Completed 2026-11-19T03:02:44.174765Z 024574a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

chore(web): migrate to Tailwind CSS v4

2 participants