Class Preview

Represents a single preview configuration for a component.

Inheritance
Preview
Namespace: BlazorToolkit.Previews
Assembly: BlazorToolkit.Previews.dll
Syntax
public class Preview

Constructors

Preview()

Declaration
public Preview()

Properties

AssetRoots

Per-preview asset roots (project-relative), appended to the IPreviewHost defaults for this preview.

Declaration
public List<string> AssetRoots { get; set; }
Property Value
Type Description
List<string>

CascadingValues

Cascading values to supply around the component when rendered.

Declaration
public List<CascadingValueSpec> CascadingValues { get; set; }
Property Value
Type Description
List<CascadingValueSpec>

HttpMock

Routed stub HTTP responses (method + path), for components that call more than one endpoint. When set, the stub matches a request against these rules first; unmatched requests fall back to Default, then HttpResponse, then a benign 200. Null uses the single HttpResponse.

Declaration
public PreviewHttpMock? HttpMock { get; set; }
Property Value
Type Description
PreviewHttpMock

HttpResponse

Canned response returned by the preview host's stub HttpClient/IHttpClientFactory when no HttpMock rule matches. Null uses a benign default (200, "null" JSON).

Declaration
public PreviewHttpResponse? HttpResponse { get; set; }
Property Value
Type Description
PreviewHttpResponse

Layout

Layout component (a LayoutComponentBase) to wrap the previewed component in, as its Body. Null means "inherit": the effective layout is the IPreviewHost default (if the host set one via UseLayout) else none. Set explicitly via WithLayout<TLayout>(), which overrides the host default for this preview.

Declaration
public Type? Layout { get; set; }
Property Value
Type Description
Type

Location

Relative location (e.g. "/orders?tab=open") that sets the preview NavigationManager's current URI. Null means the site root.

Declaration
public string? Location { get; set; }
Property Value
Type Description
string

Name

Display name of the preview.

Declaration
public string Name { get; set; }
Property Value
Type Description
string

Parameters

Parameter values to pass to the component (includes child content, stored as a RenderFragment).

Declaration
public Dictionary<string, object?> Parameters { get; set; }
Property Value
Type Description
Dictionary<string, object>

Scripts

Per-preview scripts (project-relative), appended to the IPreviewHost defaults for this preview.

Declaration
public List<string> Scripts { get; set; }
Property Value
Type Description
List<string>

ServiceConfigurators

Escape hatch for registering additional services (e.g. a component library's Add*) into the render container.

Declaration
public List<Action<IServiceCollection>> ServiceConfigurators { get; set; }
Property Value
Type Description
List<Action<IServiceCollection>>

Services

Service overrides for this specific preview — real instances (Inject) or stubs (Mock).

Declaration
public Dictionary<Type, object> Services { get; set; }
Property Value
Type Description
Dictionary<Type, object>

Strategy

Which renderer this preview uses. Null means "inherit": the effective strategy is the IPreviewHost default (if the host set one) else Interactive. Set explicitly via RenderInteractive() / RenderStatic().

Declaration
public RenderStrategy? Strategy { get; set; }
Property Value
Type Description
RenderStrategy?

Stylesheets

Per-preview stylesheets (project-relative), appended to the IPreviewHost defaults for this preview.

Declaration
public List<string> Stylesheets { get; set; }
Property Value
Type Description
List<string>

User

The authenticated user for this preview, driving AuthorizeView and cascading auth state. Null means anonymous (the default).

Declaration
public ClaimsPrincipal? User { get; set; }
Property Value
Type Description
ClaimsPrincipal