Skip to content

Commit b01bfa8

Browse files
committed
feat: 增加 ChildContent 模板
1 parent 5420721 commit b01bfa8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@
44
@if (IsInputGroupLabel)
55
{
66
<div @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
7-
<span>@DisplayText</span>
7+
@if (ChildContent != null)
8+
{
9+
@ChildContent
10+
}
11+
else
12+
{
13+
<span>@DisplayText</span>
14+
}
815
</div>
916
}
1017
else
1118
{
12-
<label @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">@DisplayText</label>
19+
<label @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
20+
@if (ChildContent != null)
21+
{
22+
@ChildContent
23+
}
24+
else
25+
{
26+
@DisplayText
27+
}
28+
</label>
1329
}

src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public partial class BootstrapInputGroupLabel
4141
[Parameter]
4242
public bool ShowRequiredMark { get; set; }
4343

44+
/// <summary>
45+
/// Gets or sets the child content. Default is null.
46+
/// </summary>
47+
[Parameter]
48+
public RenderFragment? ChildContent { get; set; }
49+
4450
private string? Required => ShowRequiredMark ? "true" : null;
4551

4652
private bool IsInputGroupLabel => InputGroup != null;

0 commit comments

Comments
 (0)