Skip to content
GitHub11 stars

Add Blazix.Primitives to your Blazor app and set it up.

Install the library

Add the package to your Blazor app:

dotnet add package Blazix.Primitives

All the primitives are in this one package. You don't add a <script> tag: each primitive's JavaScript module ships inside the package and is imported the first time the primitive is used. If you use the styled components, dnx Blazix.Cli init has already added it.

Set up

Render mode

The primitives need an interactive render mode. They're tested with Interactive Server, for example set for the whole app:

Components/App.razor
<Routes @rendermode="InteractiveServer" />

Imports

Import the namespace in the files that use the primitives, or once in _Imports.razor:

Components/_Imports.razor
@using Blazix.Primitives

Some parts share a name with a styled component (AccordionItem, DialogTrigger...), and Razor can't tell two components with the same tag apart. If you use both, import Blazix.Primitives only in the folders that use the primitives directly, or write the full name, as in <Blazix.Primitives.DialogPopup>.

Popups

Popups such as Dialog, Menu and Popover render in the browser's top layer, so they appear above the rest of the page whatever its z-index and overflow styles. They aren't moved into a portal: they stay where you wrote them in the DOM, so cascading values, CSS isolation and a .dark class on any wrapper still apply to them.

Next steps

Assemble your first component, then read the handbook on styling the primitives.