tailpress: Can not add custom colors / text sizes to Theme.json

Hi,

There seems to be something wrong with the variables in theme.json

As you can see, the --wp–preset–font-size–2xl - 9xl are not found.

Image

The same happens when I want to add colors to the palette. I have added a custom color to the Wordpress palette:

 "palette": [
        {
          "name": "Primary",
          "slug": "primary",
          "color": "#0EA5E9"
        },
        {
          "name": "Secondary",
          "slug": "secondary",
          "color": "#14B8A6"
        },
        {
          "name": "Rood",
          "slug": "rood",
          "color": "#FF0000"
        },

However, I can not use this in theme.css like this:

 --color-primary: var(--wp--preset--color--primary);
    --color-secondary: var(--wp--preset--color--secondary);
    --color-rood: var(--wp--preset--color--rood); 

It seems that only the standard Wordpress presets are working ( text sizes xs - xl and colors primary + secondary ) .

What am I missing here?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I have added a note on it in the docs both with colors and fonts.

What should be documented @filip-van-hoeckel? The way colors are defined in v4 is documented here: https://tailpress.io/docs/5.0/colors

The fact that you can’t use numbers in de color names. However, this also belongs to the tailwind docs and not the tailpress docs in my opinion

@imhugos in addition to the comment of jeffreyvr:

When you define colors in theme.json, you need to define them in theme.css as well.

For instance; when you add this color in theme.json:

"color": {
      "palette": [
        {
          "name": "purple",
          "slug": "purple",
          "color": "#8801FD"
        },

you should also add that color to the theme.css file like this:

--color-purple: var(--wp--preset--color--purple);

This was automated in Tailpress V3 using javascript; the new way feels like a step back for me. Same goes for working with CSS layers in Tailwind V4. This is really annoying; since Wordpress and plugins are not putting their css in css layers. I’m thinking of reverting back to Tailwind V3 for this reason.