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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(