Skip to content

feat: tailwind support#686

Open
Swanand01 wants to merge 15 commits into
theme-elementary-v2from
feat/tailwind-support
Open

feat: tailwind support#686
Swanand01 wants to merge 15 commits into
theme-elementary-v2from
feat/tailwind-support

Conversation

@Swanand01
Copy link
Copy Markdown

@Swanand01 Swanand01 commented May 14, 2026

Description

Integrates Tailwind CSS v4 into the webpack build pipeline as a proof of concept.

Technical Details

  • Added postcss.config.js with @tailwindcss/postcss — required for @wordpress/scripts to hand PostCSS control to Tailwind
  • Entry point: src/css/frontend/tailwind.css — compiled to assets/build/css/frontend/tailwind.css
  • Preflight disabled (imports only theme.css + utilities.css) to avoid conflicts with WP block styles
  • Tailwind output is in @layer utilities, so unlayered WP block styles always win specificity conflicts
  • Design tokens in @theme {} map Tailwind utility names to WP CSS custom properties from theme.json (colors, font sizes, font families, spacing, layout widths)
  • Opt-in: only enqueued when src/css/frontend/tailwind.css exists
  • v4 auto content detection — no @source directives needed

Checklist

  • tailwindcss and @tailwindcss/postcss added as dev dependencies
  • postcss.config.js configured with @tailwindcss/postcss (autoprefixer omitted — built into v4)
  • Preflight disabled by importing only theme.css + utilities.css, omitting preflight.css
  • Design tokens from theme.json mapped in @theme {} — colors, font sizes, font families, spacing, layout widths
  • Tailwind output in @layer utilities — WP block styles always win, no visual regressions in the editor
  • At least one Tailwind utility used in a template and verified in compiled CSS output and browser
  • npm run build:prod produces purged, production-ready CSS
  • npm run start watch mode works
  • No tailwind.config.js needed — v4 uses CSS-first config via @theme {}
  • Content detection automatic via Tailwind v4 — no @source directives needed
  • Opt-in: only enqueued when src/css/frontend/tailwind.css is present
  • DEVELOPMENT.md updated with integration notes and preflight decision

Fixes/Covers issue

Fixes #644

@Swanand01 Swanand01 self-assigned this May 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Integrates Tailwind CSS v4 into the existing webpack/PostCSS build pipeline as a proof-of-concept, opt-in via the presence of a single source file. Design tokens are bridged to existing theme.json CSS custom properties so Tailwind utilities stay visually aligned with WordPress block styles, and Preflight is intentionally omitted to avoid resetting block editor styles.

Changes:

  • Adds @tailwindcss/postcss (and autoprefixer, tailwindcss) dev dependencies and a postcss.config.js enabling Tailwind v4 in PostCSS.
  • Adds src/css/frontend/tailwind.css with @theme {} mappings to --wp--preset--* tokens, and conditionally registers/enqueues the compiled stylesheet from Assets.php only when the source file exists.
  • Tightens webpack watch options to ignore node_modules and assets/build, and documents the Tailwind integration in DEVELOPMENT.md.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Adds tailwindcss, @tailwindcss/postcss, and autoprefixer as dev dependencies
package-lock.json Lockfile regenerated; adds Tailwind/lightningcss/oxide trees and many unrelated peer-flag churn
postcss.config.js New PostCSS config wiring @tailwindcss/postcss
src/css/frontend/tailwind.css New Tailwind v4 entry mapping @theme tokens to WP CSS custom properties
webpack.config.js Adds watchOptions to ignore node_modules and build output
inc/Core/Assets.php Detects opt-in via file presence and conditionally registers/enqueues the Tailwind stylesheet
DEVELOPMENT.md Documents Tailwind integration, preflight decision, and opt-in mechanism

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json Outdated
Comment thread inc/Core/Assets.php Outdated
Comment thread DEVELOPMENT.md
Copy link
Copy Markdown
Member

@aryanjasala aryanjasala left a comment

Choose a reason for hiding this comment

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

Please address the Copilot feedbacks as well

Comment thread src/css/frontend/tailwind.css Outdated
Comment thread inc/Core/Assets.php Outdated
Comment thread webpack.config.js Outdated
Comment thread inc/Core/Assets.php Outdated
Comment thread src/css/frontend/tailwind.css Outdated
@Swanand01 Swanand01 requested a review from aryanjasala May 20, 2026 08:06
@@ -0,0 +1,29 @@
/* Auto-generated from theme.json by GenerateTailwindThemePlugin */
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.

The comment says "Auto-generated from theme.json by GenerateTailwindThemePlugin" but this file is committed to the repo and there's no such plugin in the PR.

Comment thread DEVELOPMENT.md

**Design tokens:** The `@theme {}` block in `tailwind.css` maps Tailwind utility names to WordPress CSS custom properties generated from `theme.json` (e.g. `--color-primary: var(--wp--preset--color--primary)`). This means tokens stay in sync with `theme.json` automatically — no manual duplication.

**Content detection:** Tailwind v4 automatically detects template files. No explicit content globs are needed.
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.

The documentation states "Content detection automatic via Tailwind v4 — no @source directives needed" but src/css/frontend/tailwind.css line 2 explicitly has @source "../../../";. This is contradictory.

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.

3 participants