diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs b/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs index c9771473b02..cea7a398424 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs @@ -27,6 +27,7 @@ public partial class DateTimePicker /// private string? InputClassName => CssBuilder.Default("dropdown-toggle form-control datetime-picker-input") .AddClass("has-icon", ShowIcon) + .AddClass($"border-{Color.ToDescriptionString()}", Color != Color.None && !IsDisabled && !IsValid.HasValue) .AddClass(ValidCss) .Build(); @@ -105,6 +106,12 @@ public string? Format [Parameter] public bool ShowIcon { get; set; } = true; + /// + /// 获得/设置 控件边框颜色样式 默认为 None 显示 + /// + [Parameter] + public Color Color { get; set; } = Color.None; + /// /// 获得/设置 组件显示模式 默认为显示年月日模式 /// diff --git a/test/UnitTest/Components/DateTimePickerTest.cs b/test/UnitTest/Components/DateTimePickerTest.cs index 3ce55ebfdca..4bf31c1d247 100644 --- a/test/UnitTest/Components/DateTimePickerTest.cs +++ b/test/UnitTest/Components/DateTimePickerTest.cs @@ -10,6 +10,18 @@ namespace UnitTest.Components; public class DateTimePickerTest : BootstrapBlazorTestBase { #region DateTimePicker + [Fact] + public void Color_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.AutoToday, true); + pb.Add(a => a.Value, DateTime.MinValue); + pb.Add(a => a.Color, Color.Primary); + }); + cut.Contains("border-primary"); + } + [Fact] public void AutoToday_DateTime() {