Skip to content

Modern Tailwind v4 CSS not fully supported in WeasyPrint 68.1 #2682

@dhinesh-kumar-m

Description

@dhinesh-kumar-m

We are generating invoice PDFs using WeasyPrint 68.1.

The PDF renders successfully (no runtime errors), but layout and styling differ significantly from browser rendering when using CSS compiled from Tailwind CSS v4.1.18.

Tailwind v4 output includes modern CSS such as:

@layer theme {
  :root {
    --spacing: .25rem;
    --color-stone-800: oklch(26.8% .007 34.298);
  }
}

@layer utilities {
  .size-3 {
    width: calc(var(--spacing) * 3);
    height: calc(var(--spacing) * 3);
  }

  .fill-stone-800 {
    fill: var(--color-stone-800);
  }
}

When rendered with WeasyPrint 68.1, we see warnings such as:

  • Invalid or unsupported selector ':root,:host'
  • Unknown rule @supports
  • Ignored padding-inline-start
  • Invalid media type '(min-width:40rem)'
  • Invalid media type '(prefers-color-scheme:dark)'
  • Ignored fill:var(--color-stone-800)

As a result:

  • Logical properties (margin-inline, etc.) are ignored
  • Modern media queries are ignored
  • @supports rules are ignored
  • oklch() colors may not apply
  • Some CSS variables used inside calc() do not behave as in browsers

The PDF renders, but styling is incomplete or incorrect compared to browser output.


Environment

  • WeasyPrint: 68.1
  • Python: 3.12.3
  • OS: Linux (WSL2)
  • Tailwind CSS: 4.1.18

Question

Does WeasyPrint 68.1 officially support:

  • @layer
  • CSS custom properties (var())
  • Logical properties (margin-inline, etc.)
  • oklch() color functions
  • Modern media queries (min-width, prefers-color-scheme)
  • @supports at-rules

If not, is preprocessing required before rendering CSS from modern frameworks like Tailwind v4?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions