Skip to content

Commit 61bca99

Browse files
committed
Add OnNullText and OnNullContent parameters to LocalTimeText component usage examples
1 parent f01e5a9 commit 61bca99

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/API.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Displays formatted local time text.
3636
| `Value` | `DateTimeOffset?` | - | UTC datetime to display |
3737
| `Format` | `string` | `"yyyy-MM-dd HH:mm:ss"` | Display format string |
3838
| `DisableTimeElement` | `bool` | `false` | Whether to wrap in `<time>` element |
39+
| `OnNullText` | `string?` | `null` | Text to display if `Value` is null |
40+
| `OnNullContent` | `RenderFragment?` | `null` | Content to display if `Value` is null |
3941

4042
### `LocalTime`
4143
Provides local time via render fragment with loading and error state support.

example/BlazorLocalTimeSample/Pages/Home.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@
6969
<LocalTimeText Value="@DateTime.UtcNow" Format="yyyy-MM-dd HH:mm:ssK" />
7070
</div>
7171

72+
<p>
73+
If you want to specify what to display when the value is null, you can use the <code>OnNullText</code> or <code>OnNullContent</code> parameters.
74+
</p>
75+
76+
<pre><code class="language-razor">&lt;LocalTimeText Value="@@null" DisableTimeElement OnNullText="No date available" /&gt;</code></pre>
77+
78+
<div class="component-sample">
79+
<LocalTimeText Value="@null" DisableTimeElement OnNullText="No date available" />
80+
</div>
81+
7282
<p>
7383
Alternatively, you can use the <code>LocalTime</code> component to receive the converted value in the child content:
7484
</p>

0 commit comments

Comments
 (0)