Introduction
Get Started
Create a twblazor Blazor Web App with the project template, or add twblazor to an existing Server or WebAssembly app.
Last updated
Start from the project template
The Project template tab creates a complete app in one command: solution, pages, theme, Tailwind CSS and a dashboard, sidebar, navbar or blank layout. Use the other tabs to create the project yourself or add twblazor to an existing app, and the Theme builder to change the default theme.
Choose a starting point
Pick the render mode and starting layout. The commands below update to match.
Render mode
Layout
Install and create in one line
Install the templates tool and create the app in one PowerShell line. This works even if you have not installed twblazor.templates yet:
dotnet tool install -g twblazor.templates; twblazor new MyApp -i server -t dashboard
Use ; rather than && on Windows PowerShell 5.1. PowerShell 7 accepts either.
1. Install the templates tool
The twblazor.templates .NET tool installs the project templates and creates a complete app: the solution, pages, theme, Tailwind build and a dashboard, sidebar, navbar or blank layout. Install it once:
dotnet tool install -g twblazor.templates
The command it puts on your PATH is twblazor; the package is twblazor.templates. This is a .NET tool, so install it with dotnet tool install, not dotnet new install.
2. Create the app
This creates a Server app with the
Dashboard layout. It installs the templates, creates the solution, restores packages and builds the Tailwind stylesheet. Replace MyApp with your own project's name:
twblazor new MyApp -i server -t dashboard
Change the render mode or layout in the first card and this command updates automatically. twblazor new is the only command you need after the tool is installed. twblazor install only registers the templates with dotnet new; it does not create an app.
3. Choose the render mode and layout
The first card sets the render mode and layout used by the commands above. Every option can also be passed in any order:
| Option | Values | Default |
|---|---|---|
-i, --interactivity |
server, wasm (or webassembly), auto |
server |
-t, --template |
dashboard, sidebar, navbar, blank |
dashboard |
-f, --framework |
net11.0, net10.0 |
net11.0 |
-o, --output |
Folder to create the app in | ./MyApp |
--no-restore |
Skip dotnet restore |
Restore runs |
--no-npm |
Skip npm install and the Tailwind build |
Both run |
--force |
Write into a folder that is not empty | Refuses |
4. Run it
The command prints the same instructions when it finishes. Build the HTTP launch profile the first time so you do not need a development certificate just to preview:
cd MyApp
dotnet run --project MyApp --launch-profile http
Open MyApp.slnx in Visual Studio to work on it there. The generated .vsconfig asks for the ASP.NET and web development workload, which is all the app needs.
For WebAssembly and Auto, run the host project (MyApp), not MyApp.Client.