Skip to content

Not detecting class names with template literals #6559

@harryzcy

Description

@harryzcy

What version of Tailwind CSS are you using?

v3.0.5

What build tool (or framework if it abstracts the build tool) are you using?

Vite 2.7.2 8.3.1, postcss 8.4.5, autoprefixer 10.4.0

What version of Node.js are you using?

v16.13.0

What browser are you using?

Chrome

What operating system are you using?

macOS

Describe your issue

When class names are contained in template literal strings, they are not picked up by the parser unless a trailing space is supplied. The template literals are common when using frameworks like React.

In the following example, 'overflow-scroll' is not picked up:

<div className={`overflow-scroll${conditionIsOpen ? '' : ' hidden'}`}></div>

This workaround works:

<div className={`overflow-scroll ${conditionIsOpen ? '' : ' hidden'}`}></div>

But it will result in an extra space between class names.

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