question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tailwind does not recognize classes on the angular component tag

See original GitHub issue

I have two components called button and text-box and I use sass to style them. To do this, I gave each component a class like the following:

textbox component:

@Component({
  selector: 'my-text-box',
  template:`<input type="text">`,
  host: { class: 'editor-container' },
})
export class MyTextBoxComponent {}
@layer components {
    .editor-container {
        @apply block bg-white shadow-sm border border-solid border-black;
    }
}

button component:

@Component({
  selector: 'my-button',
  template:`
  <button>
    Hello
  </button>
  `,
  host: { class: 'my-button' },
})
export class MyButtonComponent implements OnInit {
  constructor() {}

  ngOnInit(): void {}
}
@layer components {
    .my-button {
        & > button {
            @apply p-5 text-sm relative inline-flex items-center justify-center select-none font-medium whitespace-nowrap overflow-hidden text-ellipsis transition-all bg-blue-600;
        }
    }
}

The problem arises when the style of my class does not load if the name of the component tag is not the same. For example, I change the "editor-container" class with a “my-text-box”. Everything works fine. (I need this feature to develop components). In fact, if the class name and tag are the same, the style will be added.

Is this a bug? Can I use Customizing extraction logic to set tailwind to check tags in addition to classes?

framework: Angular version 14.0.0 tailwind version: 3.1.4 nodejs version: 16.15.0 browser: Chrome operating system: macOS, Windows

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
asafari72commented, Jun 27, 2022

Hi, Has anyone found a solution?

1reaction
thecrypticacecommented, Jun 22, 2022

@asafari72 Would you mind providing a small reproduction repo that I can clone with instructions? I don’t quite understand what the problem is that you’re describing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Many Tailwind CSS classes doesn´t work on my Angular 12 ...
For some reason, in my styles.scss, I had to import the variables as follows @import 'tailwindcss/base'; @import 'tailwindcss/components'; ...
Read more >
Cleaner CSS in your component templates with Tailwind and ...
Headwind is an opinionated Tailwind CSS class sorter for Visual Studio Code. It enforces consistent ordering of classes by parsing your code and ......
Read more >
Tailwind CSS - Rapidly build modern websites without ever ...
Rapidly build modern websites without ever leaving your HTML. A utility-first CSS framework packed with classes like flex , pt-4 , text-center and...
Read more >
Why React uses className over class attribute
In fact, in earlier times before React 16, if you wrote JSX with an unknown element that does not recognize by React, it...
Read more >
How to Add Tailwind CSS to Your Angular Application
With this, Tailwind will process the @tailwind directives and inject its base , components , and utilities classes. 6. Enjoy! You can now...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found