Replies: 10 comments 20 replies
-
What if the source is from npm root? How do we configure... |
Beta Was this translation helpful? Give feedback.
-
out.css shows errors |
Beta Was this translation helpful? Give feedback.
-
Thanks for the post. |
Beta Was this translation helpful? Give feedback.
-
This was super helpful, thanks for taking the time to share the info. One change I would make is that you should still go ahead and create your own The CLI still uses the config file and if you want to add plugins or if say the files you want the CLI to watch are in a non-standard place or non-standard file types you may end up in a world of hurt until you figure it out. |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking the time to put this document together. The official documentation for standalone CLI users appears to be lacking, at this time. I have following your instructions, however I'm encountering the following issue: input.css: When running
Do you have any thoughts on whats happening here? It appears that the import directive is causing the standalone cli to look for a 'tailwindcss' package, in the css directory, but obviously, it isn't there. Kind regards |
Beta Was this translation helpful? Give feedback.
-
Thanks for the guide, migrating from v3, using a config which pulls in
it works perfectly locally when running on windows, but fails when building with My in.css has been simplified to just load the config;
I've tried only importing one of the plugins, both fail individually too. If i remove both... build succeeds! Anyone have any ideas? / using plugins with the standalone cli in v4, on a linux build? |
Beta Was this translation helpful? Give feedback.
-
This is the only documentation out there that explains how to configure the Standalone CLI for Tailwind v4. Thank you so much. @tailwindlabs can you guys please update your documentation and properly support Standalone CLI? There are a lot of us outside the npm ecosystem that would love to use Tailwind without having to rely on npm in our project. |
Beta Was this translation helpful? Give feedback.
-
Hello, thank you for the tutorial. One thing I struggle with is uninstalling the @base component. The old way of adding tailwindcss meant this was straightforward:
Becomes:
Now there is only one instruction to add to my
I've found some documentation that says this can be done in
Other elements in the config are otherwise working. There are two reasons why I'd like to be able to easily remove base styles - debugging, and for projects like for example WordPress theming when I'd like to use Tailwind for a child theme without double loading all the preflight styles included in the parent theme. |
Beta Was this translation helpful? Give feedback.
-
In the latest Tailwind installation for Vite+React , the command |
Beta Was this translation helpful? Give feedback.
-
Thank you for the guide @verachell. For people that are running Alpine Linux (or any other Linux with musl), make sure you download the musl binary; otherwise, your binary will not work. |
Beta Was this translation helpful? Give feedback.
-
I felt there was a need for a beginner tutorial for those getting started with the tailwind v 4 standalone CLI (no node.js, no npm). Particularly for those who had the v 3 standalone CLI working fine, the v 4 has quite a few differences. Most of the official documentation for v 4 refers to the node.js versions, not the standalone.
I pieced this together from various GH discussions, issues and the official documentation when trying to set up the Tailwind 4 standalone CLI with one of my projects. I wanted to put the info together all in one place in case it helps others, particularly beginners who just want an easy step by step guide.
The good news is that it's super-easy - it's actually easier to use Tailwind v 4 than v 3 with the standalone CLI.
This tutorial was done with Tailwind release v 4.0.0 in a Linux environment.
1. Download the tailwind binary
Go to the latest release of tailwind on GitHub at https://github.com/tailwindlabs/tailwindcss/releases/ and find the appropriate one for you operating system. Then download it - here's an example with the Linux version
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.0/tailwindcss-linux-x64
you will see the name of the tailwind executable in your working directory. It will be called something like
tailwindcss-linux-x64
Give it execute permissions
chmod u+x tailwindcss-linux-x64
Then change the name to tailwindcss for convenience
mv tailwindcss-linux-x64 tailwindcss
2. Tell Tailwind where your source files are
The biggest difference here from v 3 is that there is no init step. In fact, if you try to use the init command you will get an error.
You also won't need a tailwind.config.js file for a standard simple setup - UNLESS as @standingwave helpfully pointed out in the comment below #15855 (comment) , you are using plugins and/or you can't easily specify in one line the directory where the source files are to be watched, and/or you need to specify file types that tailwind otherwise wouldn't look at, THEN you should use a tailwind.config.js file. If this is you, see that comment link thread for more information on how to do that. It will be more likely to apply if you're upgrading from 3 to 4, but may still apply for certain 4.0.0 setups.
Instead, you need an input file with a minimum of 1 line. I call it
in.css
but you can call it anything you like. In that file, put this line (but read on if your website files are not in the same directory):in.css:
@import "tailwindcss";
BUT - this does not tell Tailwind where your source files are. If you do not specify, Tailwind will assume by default that the root of your source files is the same as your current Tailwind working directory. Therefore, if your website files do not have the same root directory as your Tailwind working directory, you will need to specify to Tailwind where to look.
You do this by modifying that line in the
in.css
file to specify the root directory of your source files. In the example shown below, the root of my source files was 2 levels above my Tailwind working directory. Adjust your path as appropriate.in.css:
@import "tailwindcss" source("../..");
For an alternative way to indicate sources, take a look at the comment below by @arashThr at #15855 (comment)
3. Have Tailwind generate your css file
Then get Tailwind to generate the css file for your project, specifying your desired input file and output files. e.g.
./tailwindcss --input in.css --output out.css
In this example, Tailwind generates the
out.css
which is the css file to use in your website.You can now use the Tailwind CSS classes in your project.
If you're making changes on the fly, you may prefer to use the --watch option e.g.
./tailwindcss --input in.css --output out.css --watch
This means you don't have to run the./tailwindcss
command every time you change your css classesOptional: additional info (ignore this for straightforward situations)
Beta Was this translation helpful? Give feedback.
All reactions