Skip to content
GitHub11 stars

Configures CSP-related behavior for inline tags rendered by the primitives.

CspProvider cascades a Content Security Policy nonce to the components inside it. The primitives themselves never inject <style> or <script> elements: their browser-side styles are set through the CSSOM, which CSP allows, and their scripts are ES modules loaded from the package's static assets. So nothing in the package needs the nonce today. It's there, as CspSettings, for parts you build that do.

Some parts render inline style attributes (positions and sizes), which need style-src-attr 'unsafe-inline' under a strict policy, since Blazor sets them as attributes.

Anatomy

@using Blazix.Primitives

<CspProvider Nonce="@nonce">
    ...
</CspProvider>

API Reference

CspProvider

Doesn't render its own HTML element.

ParameterTypeDefault
Nonce string? -
DisableStyleElements bool false
ChildContent

The part's content.

RenderFragment? -

CspSettings