Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Footer
  • MenuNew
  • Navbar
  • On This PageNew
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Button
  • Checkbox
  • Color Picker
    • Date
    • Date Range
    • Datetime
    • Datetime Range
    • Time
    • Time Range
  • File Upload
  • NumericNew
  • Radio Button
  • RatingNew
  • Select
  • Slider
  • Switch
  • Textfield
  • Alert
  • Avatar
  • Chip
  • Icon
  • Progress
  • Skeleton
  • Spinner
  • TooltipNew
  • Data Table
  • Pagination
  • Pick List
  • BarcodeNew
  • QR CodeNew
  • CalendarNew
  • Table
  • Overview
  • Area
  • Bar
  • Box Plot
  • Bullet
  • Bump
  • Candlestick
  • Column
  • Dot Plot
  • Dumbbell
  • Funnel
  • Gantt
  • Gauge
  • Heatmap
  • Histogram
  • Icon
  • Line
  • Lollipop
  • Matrix
  • Nightingale
  • Parallel Coordinates
  • Pie
  • Quadrant
  • Radar
  • Radial Bar
  • Range
  • Scatter
  • Slope
  • Small Multiples
  • Strip Plot
  • Treemap
  • Waffle
  • Waterfall
  • Arc Diagram
  • Barcode
  • Beeswarm
  • Bump Area
  • Categorical Scatter
  • Chord Diagram
  • Circular Treemap
  • Contour
  • Convex Treemap
  • Density Plot
  • Dendrogram
  • Euler Diagram
  • Flowchart
  • Hexagonal Binning
  • Horizon
  • Marimekko
  • Network Diagram
  • Radial Histogram
  • Ridgeline
  • Sankey
  • Stream Graph
  • Sunburst
  • Venn Diagram
  • Violin Plot
  • Word Cloud
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Guides

Tailwind CSS with Blazor

How to use Tailwind CSS with Blazor Server and WebAssembly, and how twblazor gives you accessible, themeable Tailwind Blazor components.

Last updated 18 October 2026

Why Tailwind with Blazor?

Tailwind CSS is a utility-first CSS framework: you style elements with small single-purpose classes such as px-4 or bg-purple-600 instead of writing stylesheets. Blazor renders Razor markup, so those classes sit directly in your components and your design lives next to the markup that uses it.

The catch is that Tailwind only generates the classes it can find as literal text in your source files. That matters the moment a component library is involved, because Tailwind cannot read the classes compiled into a NuGet package's DLL.

How Tailwind finds your classes

Tailwind scans the files you point it at with @source directives and generates CSS for every class name it finds. In a Blazor project that means your .razor files and any C# file that holds class names.

CSS
@import "tailwindcss";

@source "../../**/*.razor";
@source "../../Theme.cs";

Run the Tailwind CLI against that input file to produce output.css, then link it from App.razor (Blazor Server and Web App) or index.html (standalone WebAssembly). Nothing about Tailwind needs a Node server at runtime, only at build time.

How twblazor handles the DLL problem

twblazor is a Tailwind Blazor component library, so it solves the problem above directly. Every class a component uses is declared as a literal string in a Theme.cs file that lives in your project. Your Tailwind build scans that file alongside your Razor files and produces one stylesheet containing everything.

CSHARP
builder.Services.AddTwBlazor(_ => { }, Theme.CreateDefaultTheme);

Because the classes are plain C# strings in your own code, you can change a component's look by editing one property, with no CSS overrides and no !important. The Theme builder generates a Theme.cs with your brand colors and only the components you use.

Dark mode and accessibility

Every twblazor component ships with dark: variants, so dark mode works as soon as your app toggles the dark class on the root element. Components also include ARIA attributes and keyboard support, which you would otherwise have to build and test yourself.

Browse the button, textfield, data table and color picker pages to see live examples and the theme properties each one exposes.

Next steps

  • Follow the Get started guide to install twblazor in a Blazor Server or WebAssembly app.
  • Create your own palette with the Theme builder.
  • Read the Why twblazor? page to see what sets it apart.

Frequently asked questions

Yes. Tailwind works with Blazor Server, Blazor WebAssembly and Blazor Web Apps. You point the Tailwind CLI at your .razor files, build an output.css and link it from your host page.

Tailwind generates CSS by scanning source files for class names as literal text. Compiled assemblies are not scanned, so a library has to expose its classes in a file your own build can read. twblazor does this with a Theme.cs file in your project.

No. twblazor ships no pre-built CSS. Your own Tailwind build generates every class its components use from the Theme.cs file in your project, so the output only contains what you need.

Yes. Every component has dark mode styles and switches when the dark class is present on your root element.

twblazor is built for Tailwind CSS v4 and its @source directive based configuration, as shown in the Get started guide.

On this page

  • Why Tailwind with Blazor?
  • How Tailwind finds your classes
  • How twblazor handles the DLL problem
  • Dark mode and accessibility
  • Next steps
  • Frequently asked questions
Discord (opens in a new tab) • GitHub (opens in a new tab) • Documentation (opens in a new tab) • MIT License (opens in a new tab) • llms.txt (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload