Black Friday Super Sale! Limited Time 50% OFF for All-Access Plans
Save 50% Now

CSS import order angular


I am looking at the example project for angular: https://github.com/keenthemes/metronic-tailwind-html-integration/blob/main/metronic-tailwind-angular/angular.json

Here the "src/assets/css/styles.css" is imported last. It should therefore overwrite classes with the same name of imports before this. (tailwind color class e.g.)

Here my issue: If I define common classes in "src/tailwind.css", these should be overwritten by "src/assets/css/styles.css" ? (I dont want this)

To use tailwind I need @import "tailwindcss" though. Otherwise I cant use something like "@apply text-gray-400".

So this makes it kind of impossible to load the css in this order:

* tailwind.css
* styles.css
* custom css file (with tailwind syntax)

How is this supposed to work?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi

Yes, that order is correct. Configure it in angular.json:
"styles": [
"src/tailwind.css",
"src/assets/css/styles.css",
"src/custom.css"
]

Thank you for your sharing



Thanks!

Just to clarify:

The proper import order is this:

tailwind.css (tailwind classes etc)
src/assets/css/styles.css (metronic styling)
custom.css (my own styling, overwriting both if conflicting)



Hi

With Tailwind CSS v4, use the @reference directive in your custom CSS file. When @apply without importing Tailwind, so you can control the load order.


/* src/custom.css */
@reference "../tailwind.css";

/* Now you can use @apply without importing Tailwind again */
@layer utilities {
.custom-text {
@apply text-gray-400;
}
}

/* Regular CSS that will override styles.css */
.my-override-class {
color: blue;
/* This will override any conflicting classes from styles.css */
}


If you prefer managing imports in one place, import your custom CSS in styles.scss


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(