tailwindcss-dotnet
1.1.0
See the version list below for details.
dotnet tool install --global tailwindcss-dotnet --version 1.1.0
dotnet new tool-manifest
dotnet tool install --local tailwindcss-dotnet --version 1.1.0
#tool dotnet:?package=tailwindcss-dotnet&version=1.1.0
nuke :add-package tailwindcss-dotnet --version 1.1.0
Tailwind CSS for ASP.NET Core
A dotnet tool that simplifies the installation and usage of Tailwind CSS in ASP.NET Core projects by utilizing the stand-alone Tailwind CSS CLI.
Getting Started
Step 1: Create your project
Start by creating a new ASP.NET Core project if you don’t have one set up already. You can use any web app template of your choice.
dotnet new blazorserver -o MyProject
cd MyProject
Step 2: Install Tailwind CSS
Install dotnet tool globally, and then run the tailwind install
command to generate the tailwind.config.js
and styles\app.tailwind.css
files:
dotnet tool install --global tailwindcss-dotnet
tailwind install
Step 3: Start your build process
Run your tailwind build process with:
tailwind watch
And start the app hot-reload dev server:
dotnet run watch
Step 4: Start using Tailwind in your project
Start using Tailwind’s utility classes to style your content.
<h1 class="text-3xl font-bold underline">
Hello world!
</h1>
Developing with Tailwind CSS
Overview
Tailwind CSS is a CSS framework that uses a utility-first approach to styling elements. It allows you to apply pre-existing classes directly in your templates. The tailwindcss-dotnet
tool wraps the standalone executable of the Tailwind CSS v3 framework, which is platform-specific and not bundled within the tool. When you run the tool for the first time, it downloads and saves the required executables automatically.
It is supports the same platforms as the native Tailwind CLI executable, including Windows, macOS, and Linux.
Starting from version 3, Tailwind CSS uses the Just-In-Time (JIT) technique to generate styles. It scans specified template files for class names and generates corresponding styles only for the names it finds. This means that you cannot generate class names programmatically. If you need styles for names that don't exist in your content files, you can use the safelist option. However, it is not recommended to do so.
Installation
To use Tailwind CSS in your dotnet project, follow these steps:
- Install the tool by running the command
dotnet tool install --global tailwindcss-dotnet
. - Run the command
tailwind install
.
To run tool commands for a specific project from any location, you can use the --project
option followed by the relative file location of the project. This option applies to all tool commands. For example, tailwind build --project MyProject\MyProject.csproj
will generate the output CSS file for the specified project.
When you install the tool, it creates default styles\app.tailwind.css
and tailwind.config.js
input files, which are configured to be used within your ASP.NET Core project.
You can specify the imports you want to use, set up your @apply
rules and custom CSS, customize the Tailwind build, just like in a traditional Node installation. Note that only first-party plugins are supported.
Building for Production
Run the tailwind build
command to generate the output CSS file at wwwroot\css\app.css
. This file should be included in your app HTML layout (the installer configures this automatically).
It is recommended to not include the output CSS file in source control. Instead, run this command in your CI environment.
Building for Development
To automatically reflect changes in the generated CSS output while developing your application, run Tailwind in "watch" mode by executing the command tailwind watch
in a separate process.
If file system events are unreliable or not supported, pass the --poll
argument to use polling instead: tailwind watch --poll
.
Configuring CSS minification
By default, minified assets will be generated. If you want to change this behavior, pass a --debug
argument to the command, for example, tailwind build --debug
or tailwind watch --debug
.
Customizing Tailwind inputs or outputs
The default paths are opinionated. If you need to use custom file paths or make other changes not covered by default behavior, you can access the platform-specific executable directly by running the command tailwind exec
and passing any necessary command line arguments to the Tailwind CLI.
Override Tailwind CLI version
If you need to use a specific version of Tailwind CLI for your project, you can do so by specifying the version using the --tailwindcss
option.
For example, to use Tailwind CLI of version 3.2.1, you can use the following command:
tailwind build --tailwindcss v3.2.1
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last Updated |
---|---|---|
2.0.0-beta.2 | 156 | 3/13/2025 |
2.0.0-beta.1 | 149 | 1/26/2025 |
1.1.0 | 2,342 | 9/2/2024 |
1.0.0 | 681 | 12/22/2023 |
1.0.0-beta6 | 416 | 3/28/2023 |
1.0.0-beta4 | 291 | 2/24/2023 |
1.0.0-beta.3 | 149 | 2/23/2023 |
1.0.0-beta.2 | 147 | 2/22/2023 |
1.0.0-beta.1 | 151 | 2/21/2023 |