Skip to content

Issue with Custom Typography Variant in Tailwind v4 in _tw Theme #198

@vi-rgm

Description

@vi-rgm

Hello,

I’m currently working on a WordPress theme based on the _tw starter and have encountered an issue with the Tailwind Typography plugin when trying to define a custom variant (e.g., prose-custom-variant).

I’ve added a custom variant following the same structure as the default DEFAULT config, like this:

typography: (theme) => ({
  'custom-variant': {
    css: {
      '--tw-prose-body': theme('colors.foreground'),
      // ...
    },
  },
}),

However, when I apply prose prose-custom-variant classes on the front end, the styles don’t seem to apply.

My suspicion is either:

  • The _tw build setup doesn’t register or merge the custom variant properly, or
  • Something is overriding or preventing the variant from taking effect.

Could you please confirm:

  • Does _tw support adding custom typography variants via tailwind-typography.config.js?
  • If yes, is there a specific way to register these variants so they work with class names like prose-custom-variant?
  • Or is this an intentional limitation related to how typography is loaded or scoped in the theme?

Theme Colors Source:

  • I also wanted to understand where exactly the colors like theme('colors.foreground') come from. Does this value map directly to colors defined in the WordPress theme.json file, or are they sourced/overridden elsewhere in the _tw theme?

I tried adding the class prose prose-custom-variant dark:prose-invert prose-a:text-primary max-w-none but it still applies the default typography styles. I have verified the variant name matches, but it seems the styles for .prose-custom-variant are not present in the compiled CSS, which makes me think my custom typography config may not be loaded or merged correctly.

Image

Thanks for your excellent work on _tw! I’d love to get this resolved and continue building with the theme.

Best regards,
Vi

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions