In this tutorial, I'm going to show you how to integrate TailwindCSS to your Angular project the EZ EZ way.
This tutorial is for people that want ...
For further actions, you may consider blocking this person and/or reporting abuse
Do you understand that for Ionic 5 the installation would be the same?
I follow this tutorial but it seems somewhat extensive...
blog.andrewbrey.com/2020-07-06-usi...
I have not tried it. If you follow mine that is shorter let me know if it works with Ionic. I will credit you on the article
Yes it worked for me, but partially. For example, I had to do the imports from the file global.scss
And in the file tailwind.config.js, add the following colors in the property theme, being this way:
What remains for me is to be able to compile the CSS so that only the classes used use me, for now the utilities are imported completely :/
But it is an advance hehe!
If you want to see the complete code with Tailwind integrated in Angular 11.2 + Ionic 5, here is a baseline maintained by the Ionic Dominicana community 🥰:
🔗github.com/ionic-dominicana/ionic-...
Thank you for this article, dear.
space-y-4 === 1rem
not4px
Thank you
How would you resolve this error with SCSS Files?
dev-to-uploads.s3.amazonaws.com/i/...
That's more of a linter issue since it's not used to this type of Syxtax. If I find a way to resolve it I will let you know BUT this shouldn't affect if your app works or not
it does. an app doesn't work!
Can you send me a link to your code? mine is working perfectly fine. Also, see the github repo link I posted at the end of the tutorial
I added this:
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
.nav-bar {
@apply border-t block no-underline hover:underline py-2 text-grey-darkest hover:text-black md:border-none md:p-0;
}
to my styles.scss file. It will not compile. If I add teh same classes to HTML, it works fine.
ERROR::
Error: ./src/styles.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
SyntaxError
(7:4) C:\dev_dev\tailwind-app\styles.scss The
text-grey-darkest
class does not exist. If you're sure thattext-grey-darkest
exists, make sure that any@import
statements are being properly processed before Tailwind CSS sees your CSS, as@apply
can only be used for classes in the same CSS tree.cheers
Laura
Interesting can you post your tailwind.config.js or send me a link to your repo? I would love to help :)
Hi Pato, this is very kind. I have created a repo: github.com/pelx/tailwindcss-app
It actually works, the only problem i still cant nail is linting. I created stylelint.config.js Didn't work. cheers. Laura
Thanks, what about purging unused classes? is it done automatically?
I don't believe its done for you but in your tailwind config file this may work...
Did you see the updated section?
Nice! Thank you for the content ❤️
You are welcome sir!
I updated the tutorial with a purging section :) let me know if you think this sucks or it's good lol
I have updated the post with some purging instructions
Seguí todos tus pasos en un proyecto totalmente nuevo, de angular 11.2.0 y no funciona.
Además en este código plugins: [require('@tailwindcss/forms'),require('@tailwindcss/typography')],
hay 2 componentes que instalar y tú no lo dices.
Como te dijera en twitter, tu tutorial confunde más de lo que ayuda.
Hola Julio!
-Ya agregue mas pasos para que no te confundas Julio. Gracias por el feedback!
Saludos!
Thanks for the tutorial.
The only way I could get purging to work was to set the env variable "NODE_ENV" to "production". Does the CLI have the ability to do this automatically when a prodction build is generated?
Hi! Check out this thread let me know if it helps you
twitter.com/mgechev/status/1359892...
Thank you for this wonderful tutorial. I tried this using default setup and it is working.
However when tried it using multiple application setup but it doesn't work when I apply the tailwind classes directly in the html files. Although it does work when using @apply in the scss. files
This does not work
This work
you mean a monorepo?
Yes. 1 Angular Workspace with multiple projects.
Finally got it to working..
First I enabled purge mode while on develop environment. Also I am linking to the wrong directories.
So for monorepo with multiple projects, purge directory should point inside the projects directory
`
Easy and simple tutorial, and I spent 7 hours to make it works!!. You may be wondering why ? I cloned the GitHub repo serve it and I had the same error. Because I'm using Node 10 while Tailwind v2 dropped Node 10 support. So if you have node v10 update it to 12 at least and things will work smoothly.
Please put notice to help people from spending their time trying to do this.
Could anyone help me out? i made an custom css dark toggle mode theme.
and i want to make it with the tailwind.
stackblitz.com/edit/angular-ivy-b9...
we know that the root of the angular project is app component, so i made like this in the custom css project,
and app component ts:
isDarkEnable = false;
presentTheme$ = new BehaviorSubject('theme-light');
constructor() {}
ngOnInit() {
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
this.presentTheme$.next(savedTheme);
}
}
changeTheme() {
this.presentTheme$.value === 'theme-light'
? this.presentTheme$.next('theme-dark')
: this.presentTheme$.next('theme-light');
localStorage.setItem('theme', this.presentTheme$.value);
this.isDarkEnable = !this.isDarkEnable;
}
and the global scss is:
.theme-light {
--primary: #2577c1;
--secondary-bg: #fff;
--theme: #fff;
--header-color: rgb(194, 63, 226);
--route-link-active: #fff;
--link-color: rgb(85, 80, 80);
--border-color: rgb(85, 80, 80);
}
.theme-dark {
--primary: rgb(255, 80, 11);
--secondary-bg: #424242;
--theme: #424242;
--header-color: var(--theme);
--route-link-active: rgb(255, 80, 11);
--link-color: #fff;
--border-color: rgb(28, 214, 28);
}
now could anyone help me how to modify it in the tailwind?
Hi there,
Thanks a lot for this.
As you probably know, in sass, the @import syntax is not the recommended way of importing. We should use @use instead.
So, what about changing those @import to @use ? Would that still work as expected ?
wow.. thanks alot
this is really helpful
I would recommend this approach github.com/mw-angular/toolbox/tree...
It is very useful when you need to use tailwind in library (i.e. design-system)
Shouldn't we build css to make tailwind directive
@apply
work properly?Please add the postcss configuration in the article seems like its missing
thakns and you