diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor index 135fcb291e8..1904f073e6c 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor @@ -4,10 +4,26 @@ @if (IsInputGroupLabel) {
- @DisplayText + @if (ChildContent != null) + { + @ChildContent + } + else + { + @DisplayText + }
} else { - + } diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs index a5d4af2405b..8352b0e1ec4 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs @@ -41,6 +41,12 @@ public partial class BootstrapInputGroupLabel [Parameter] public bool ShowRequiredMark { get; set; } + /// + /// Gets or sets the child content. Default is null. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + private string? Required => ShowRequiredMark ? "true" : null; private bool IsInputGroupLabel => InputGroup != null; diff --git a/test/UnitTest/Components/InputTest.cs b/test/UnitTest/Components/InputTest.cs index 2df97903e1b..1abadf077ce 100644 --- a/test/UnitTest/Components/InputTest.cs +++ b/test/UnitTest/Components/InputTest.cs @@ -273,6 +273,13 @@ public void GroupLabel_Ok() }); Assert.Contains("DisplayText", cut.Markup); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.ChildContent, builder => builder.AddContent(0, "test-child-content")); + }); + cut.Contains("test-child-content"); + cut.DoesNotContain("DisplayText"); } [Fact]