You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -572,77 +572,43 @@ A loading progress indicator shows the loading progress of the app to users, ind
572
572
573
573
:::moniker range=">= aspnetcore-8.0"
574
574
575
-
### Blazor Web App loading progress
575
+
### Blazor Web App loading indicator
576
576
577
-
The loading progress indicator used in Blazor WebAssembly apps isn't present in an app created from the Blazor Web App project template. Usually, a loading progress indicator isn't desirable for interactive WebAssembly components because Blazor Web Apps prerender client-side components on the server for fast initial load times. For mixed-render-mode situations, the framework or developer code must also be careful to avoid the following problems:
577
+
The loading indicator used in Blazor WebAssembly apps isn't present in an app created from the Blazor Web App project template. Usually, a loading indicator isn't desirable for interactive WebAssembly components because Blazor Web Apps prerender client-side components on the server for fast initial load times. For mixed-render-mode situations, the framework or developer code must also be careful to avoid the following problems:
578
578
579
579
* Showing multiple loading indicators on the same rendered page.
580
580
* Inadvertently discarding prerendered content while the .NET WebAssembly runtime is loading.
581
581
582
582
<!-- UPDATE 10.0 Will be removed for a new feature in this area.
A future release of .NET might provide a framework-based loading progress indicator. In the meantime, you can add a custom loading progress indicator to a Blazor Web App.
585
+
A future release of .NET might provide a framework-based loading indicator. In the meantime, you can add a custom loading indicator to a Blazor Web App.
586
586
587
-
Create a `LoadingProgress`component in the `.Client` app that calls <xref:System.OperatingSystem.IsBrowser%2A?displayProperty=nameWithType>:
587
+
#### Per-component Interactive WebAssembly rendering with prerendering
588
588
589
-
* When `false`, display a loading progress indicator while the Blazor bundle is downloaded and before the Blazor runtime activates on the client.
589
+
*This scenario applies to per-component Interactive WebAssembly rendering (`@rendermode InteractiveWebAssembly` applied to individual components).*
590
+
591
+
Create a `ContentLoading` component in the `Layout` folder of the `.Client` app that calls <xref:System.OperatingSystem.IsBrowser%2A?displayProperty=nameWithType>:
592
+
593
+
* When `false`, display a loading indicator.
590
594
* When `true`, render the requested component's content.
591
595
592
-
The following demonstration uses the loading progress indicator found in apps created from the Blazor WebAssembly template, including a modification of the styles that the template provides. The styles are loaded into the app's `<head>` content by the <xref:Microsoft.AspNetCore.Components.Web.HeadContent> component. For more information, see <xref:blazor/components/control-head-content>.
596
+
If you wish to load styles for the indicator, add them to `<head>` content with the <xref:Microsoft.AspNetCore.Components.Web.HeadContent> component. For more information, see <xref:blazor/components/control-head-content>.
In a component that adopts Interactive WebAssembly rendering, wrap the component's Razor markup with the `LoadingProgress` component. The following example demonstrates the approach with the `Counter` component of an app created from the Blazor Web App project template.
624
+
In a component that adopts Interactive WebAssembly rendering, wrap the component's Razor markup with the `ContentLoading` component. The following example demonstrates the approach with the `Counter` component of an app created from the Blazor Web App project template.
659
625
660
626
`Pages/Counter.razor`:
661
627
@@ -665,13 +631,13 @@ In a component that adopts Interactive WebAssembly rendering, wrap the component
@@ -683,6 +649,140 @@ In a component that adopts Interactive WebAssembly rendering, wrap the component
683
649
}
684
650
```
685
651
652
+
#### Global Interactive WebAssembly rendering with prerendering
653
+
654
+
*This scenario applies to global Interactive WebAssembly rendering without prerendering (`@rendermode="InteractiveWebAssembly"` on the `HeadOutlet` and `Routes` components in the `App` component).*
655
+
656
+
Create a `ContentLoading` component in the `Layout` folder of the `.Client` app that calls <xref:Microsoft.AspNetCore.Components.RendererInfo.IsInteractive?displayProperty=nameWithType>:
657
+
658
+
* When `false`, display a loading progress indicator.
659
+
* When `true`, render the requested component's content.
660
+
661
+
If you wish to load styles for the indicator, add them to `<head>` content with the <xref:Microsoft.AspNetCore.Components.Web.HeadContent> component. For more information, see <xref:blazor/components/control-head-content>.
In the `MainLayout` component (`Layout/MainLayout.razor`) of the `.Client` project, wrap the <xref:Microsoft.AspNetCore.Components.LayoutComponentBase.Body%2A> property (`@Body`) with the `ContentLoading` component:
690
+
691
+
In `Layout/MainLayout.razor`:
692
+
693
+
```diff
694
+
+ <ContentLoading>
695
+
@Body
696
+
+ </ContentLoading>
697
+
```
698
+
699
+
#### Global Interactive WebAssembly rendering without prerendering
700
+
701
+
*This scenario applies to global Interactive WebAssembly rendering without prerendering (`@rendermode="new InteractiveWebAssemblyRenderMode(prerender: false)"` on the `HeadOutlet` and `Routes` components in the `App` component).*
702
+
703
+
Create a `ContentLoading` component in the `Layout` folder of the `.Client` app with a `Loading` parameter:
704
+
705
+
* When `true`, display a loading progress indicator.
706
+
* When `false`, render the requested component's content.
707
+
708
+
If you wish to load styles for the indicator, add them to `<head>` content with the <xref:Microsoft.AspNetCore.Components.Web.HeadContent> component. For more information, see <xref:blazor/components/control-head-content>.
In a component that adopts Interactive WebAssembly rendering without prerendering, wrap the component's Razor markup with the `ContentLoading` component and pass a value in a C# field to the `Loading` parameter when initialization work is performed by the component. The following example demonstrates the approach with the `Home` component of an app created from the Blazor Web App project template.
0 commit comments