Skip to content

Properties always has !important when important is set to true and using focus:* #2877

Closed
@themustafaomar

Description

@themustafaomar

There is something I believe it shouldn't behave like this
I made a component called .form-control in a separate file, when applying focus properties like this, every single property takes !important flag:

@layer components {
  .form-control {
    @apply py-2 px-4 block w-full rounded-md border border-gray-300 shadow-sm focus:outline-none focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50;
  }
}

image

This applied to focus state as well:

image

  1. It's important to know that this is happening only if I set important to true in tailwind.config.js.
  2. And when I remove focus:* properties everything working well.

Currently, I'm rolling back to the old way and it's working perfectly.

@layer components {
  .form-control {
    @apply py-2 px-4 block w-full rounded-md border border-gray-300 shadow-sm;
  }
  .form-control:focus {
    @apply outline-none border-indigo-300 ring ring-indigo-200 ring-opacity-50
  }
}

Have I misunderstood something or this is a bug?

Link to a minimal reproduction:

https://github.com/themustafaomar/tailwind-v2-apply-is-weird

Metadata

Metadata

Assignees

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