Blazorise Tailwind Usage
Quickly install Blazorise with Tailwind, one of the world's most popular Blazor UI framework.
Blazorise Tailwind provider is made possible with the help of Flowbite, an open-source Tailwind CSS Components.
Install Packages
Install-Package Blazorise.Tailwind
Install-Package Blazorise.Icons.FontAwesome
Add Static Files
Modify your project's HTML template to include the necessary CSS files. The files you add depend on whether you're working with a WebAssembly or Server project:
- For WebAssembly, update index.html.
- For Server, update _Layout.cshtml or _Host.cshtml.
- For .NET 8, update App.razor.
<head> section:
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/flowbite@4.0.1/dist/flowbite.min.css" rel="stylesheet" /> <link href="_content/Blazorise.Icons.FontAwesome/v6/css/all.min.css" rel="stylesheet"> <link href="_content/Blazorise/blazorise.css?v=2.0.0.0" rel="stylesheet" /> <link href="_content/Blazorise.Tailwind/blazorise.tailwind.css?v=2.0.0.0" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/flowbite@4.0.1/dist/flowbite.min.js"></script>
If you're interested in integrating Tailwind CSS with your Blazor projects, check out our blog post that guides you through the process of using Tailwind CSS with Blazor.
Custom Tailwind Pipeline
If you want Tailwind to generate utilities for your app while keeping Blazorise styles, build a single Tailwind output and reference it instead of the prebuilt _content/Blazorise.Tailwind/blazorise.tailwind.min.css.
-
Copy the Blazorise Tailwind build inputs from the Blazorise repository into your project:
btw-prebuild.css,blazorise.tailwind.css,btw-colors.css, andsafelist.txt. -
Extend the entry file with your own
@sourcedirectives (for example,@source "./**/*.razor"),@themeoverrides, and custom utilities. - Build one CSS file with Tailwind and include it in your app in place of the package stylesheet.
Safelist Classnames
Blazorise generates some classnames dynamically, so Tailwind content scanning might not see them. Use the provided safelist.txt file as an additional content source to keep those classes in your output.
- Keep one class per line in your safelist file and add any of your own dynamic classes there as well.
-
Reference it in your Tailwind entry file with
@source "./path/to/safelist.txt"or pass it via the Tailwind CLI--contentargument.
Add Imports
@using Blazorise
Register Services
Program.cs.
using Blazorise;
using Blazorise.Tailwind;
using Blazorise.Icons.FontAwesome;
builder.Services
.AddBlazorise()
.AddTailwindProviders()
.AddFontAwesomeIcons();
PWA & Offline Support (optional)
For information about PWAs & offline support, please take a look at our PWA docs.