Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • 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 7 November 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
twblazor

The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

Discord (opens in a new tab) GitHub(opens in a new tab)

Get started

  • Install guide
  • Theming
  • Class merging
  • Localization

Guides

  • Tailwind CSS with Blazor
  • Why twblazor?
  • Right to left
  • AI agents and skills

Resources

  • API documentation (opens in a new tab)
  • llms.txt (opens in a new tab)
  • MIT License (opens in a new tab)

Community

  • Contributing (opens in a new tab)
  • Code of conduct (opens in a new tab)
  • Report an issue (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload