Skip to content

!important Not Applied in Custom Tailwind @utility in Angular #16810

Closed
@medbenmakhlouf

Description

@medbenmakhlouf

What version of Tailwind CSS are you using?

v4.0.9

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

Angular 19.1.8

What version of Node.js are you using?

For example: v22.14.0

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction URL

N/A

Describe your issue

When defining a custom Tailwind utility using @Utility, adding ! as a prefix (e.g., !ion-opacity-0) does not generate the expected CSS with the !important flag.

/* Add application styles & imports to this file! */
@import 'tailwindcss';

@utility ion-opacity-* {
  --opacity: --value(integer);
}
@Component({
  selector: 'app-root',
  template: `
    <h1 class="ion-opacity-0!">Hello from {{ name }}!</h1>
    <!-- Expected: CSS should be generated with !important -->
    <a target="_blank" href="https://angular.dev/overview">
      Learn more about Angular
    </a>
  `,
})
export class App {
  name = 'Angular';
}

Observe that the generated CSS does not include the !important flag when using ion-opacity-0!.

Expected Behavior
The ! prefix should apply the !important flag to the generated CSS rule, ensuring higher specificity.

Actual Behavior
The generated CSS does not include !important, even when explicitly using the ! prefix in the class.

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