Documentation
On this page
Install Cirth for Blazor
Components/App.razor writes the document shell shared by every route in a
Blazor Web App. It links files from the public wwwroot/ directory through
@Assets, which resolves each path to its fingerprinted name. Cirth replaces
the template's Bootstrap link there.
Four steps: add the file, link it, write components and check it.
1 Add the file #
mkdir -p wwwroot/css
curl -o wwwroot/css/cirth.min.css \
https://cdn.jsdelivr.net/npm/@cirthcss/cirth@0.17.0/dist/cirth.min.css
2 Link it #
In Components/App.razor:
<link rel="stylesheet" href="@Assets["css/cirth.min.css"]" />
<link rel="stylesheet" href="@Assets["app.css"]" />
<link rel="stylesheet" href="@Assets["BlazorApp.styles.css"]" />
The last line is the template's bundle of scoped component styles, named after the project; keep yours as it is.
3 Write components #
Components render ordinary elements, and markup an interactive component adds later is styled the same way:
@page "/"
@rendermode InteractiveServer
<button type="button" @onclick="() => count++">Count @count</button>
@if (count > 0)
{
<article><p>Rendered after @count clicks.</p></article>
}
@code {
private int count;
}
4 Check it #
Put this forced-dark region in a page or component that uses the global stylesheet:
<section data-theme="dark">
<article>
<p>Dark, whatever the system scheme is.</p>
</article>
</section>
Run the app, then open
the page while the system uses a light theme. A dark article proves that
Cirth loaded and that data-theme="dark" is working. It remains dark when
the system switches to a dark theme.
Customization covers the --cirth-* properties; set
yours in app.css. Package and builds lists the classless,
scoped and print entry points. Return to Framework guides
for another stack.