Replies: 1 comment
-
Hi @sntran When integrating Tailwind CSS v4 with WordPress Full Site Editing (FSE), the main challenge is that both systems define and use CSS variables differently:
Unifying Tailwind and WordPressTo unify them, you can map WordPress variables to Tailwind variables inside your @theme {
--color-base: var(--wp--preset--color--base);
--spacing-auto: var(--wp--preset--spacing--auto);
} This way:
Best Practice
By doing this, you avoid conflicts, keep WordPress's editor in sync with the frontend, and leverage Tailwind's utilities without redefining values twice. References: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
If you work with WordPress' Full Site Editing and integrate Tailwind v4 with it, welcome!
I'd like to discuss a challenge I'm facing and to see some ideas come out of this.
As we all know, with Tailwind, we define our theme in
@theme { ... }
, with--color-*
,--spacing-*
CSS custom variables. These variables are then used for utility classes liketext-*
,bg-*
,border-*
,my-*
, etc...For WordPress with its new Full Site Editing, a
theme.json
with settings for colors, spacing, ... is used:For each of those settings, WordPress generates a CSS variable, i.e.
--wp--preset--color--base: #FFFFFF
,--wp--preset--spacing--auto: auto
, ...The challenge I have is to figure out where I should actually define my theme. Should the colors be in "theme.json" or "theme.css"?
If I define the colors in
@theme
, then I would need to setsettings.color.palette[0].color = "var(--color-base)"
. Otherwise, I would need to define--color-base: var(--wp--preset--color--base);
in@theme
.Another challenge is that while Tailwind uses
text-base
,bg-base
for setting colors, WordPress generateshas-base-color
andhas-base-background-color
.Is there a way to unify them?
Beta Was this translation helpful? Give feedback.
All reactions