The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

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 (5)

The key is to control Tailwind’s CSS layers and avoid relying solely on Angular’s stylesheet import order. Using @layer for custom rules can give you more predictable precedence while still allowing @apply to work as intended.

For anyone interested in related financial planning, these tax resources may also be useful.

The issue is mainly about CSS cascade order and how Tailwind’s generated utilities interact with imported styles. One approach is to keep Tailwind source definitions separate from the final compiled CSS and use explicit layers or specificity rather than relying only on import order. That can make the intended precedence much easier to maintain as the Angular project grows. This guide may also provide useful context for organizing a separate topic: professional tax and accounting services.


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  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.