Skip to content

Commit a681ae8

Browse files
authored
Add RendererInfo examples (#34116)
1 parent 38acaae commit a681ae8

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

aspnetcore/blazor/components/render-modes.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,30 @@ The <xref:Microsoft.AspNetCore.Components.ComponentBase.RendererInfo?displayProp
226226
* `InteractiveAuto` for Interactive Auto.
227227
* `InteractiveWebAssembly` for Interactive WebAssembly.
228228

229-
Components use these properties to render content depending on their location or interactivity status. For example, a form can be disabled during prerendering and enabled when the component becomes interactive:
229+
Components use these properties to render content depending on their location or interactivity status. The following examples demonstrate typical use cases.
230+
231+
Display content until a component is interactive:
232+
233+
```razor
234+
@if (!RendererInfo.IsInteractive)
235+
{
236+
<p>Connecting to the assistant...</p>
237+
}
238+
else
239+
{
240+
...
241+
}
242+
```
243+
244+
Disable a button until a component is interactive:
245+
246+
```razor
247+
<button @onclick="Send" disabled="@(!RendererInfo.IsInteractive)">
248+
Send
249+
</button>
250+
```
251+
252+
Disable a form during prerendering and enable the form when the component is interactive:
230253

231254
```razor
232255
<EditForm Model="Movie" ...>
@@ -256,7 +279,7 @@ Components use these properties to render content depending on their location or
256279
}
257280
```
258281

259-
The next example shows how to render markup to support performing a regular HTML action if the component is statically rendered:
282+
Render markup to support performing a regular HTML action if the component is statically rendered:
260283

261284
```razor
262285
@if (AssignedRenderMode is null)

0 commit comments

Comments
 (0)