
InputGroup
Input can add lables and buttons before or after it to make as a group
Basic usage
Add a label before the Input
, or Add a Button
after the Input
Demo
UserName
@inject IStringLocalizer<InputGroupsNormal> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo
<div>
<div class="row g-3">
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="@Localizer["InputGroupsNormalUserName"]" />
<BootstrapInput @bind-Value="@BindValue" />
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInput @bind-Value="@BindValue" />
<Button Icon="fa-solid fa-magnifying-glass"></Button>
</BootstrapInputGroup>
</div>
</div>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
private string BindValue { get; set; } = string.Empty;
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
Model = Foo.Generate(LocalizerFoo);
}
}
Add multiple components
The InputGroup
can have lots of children
Demo
Distance
km
@
@inject IStringLocalizer<InputGroupsMultiple> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo
<div>
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="@Localizer["InputGroupsMultipleDistance"]" />
<BootstrapInput @bind-Value="@BindValue" />
<BootstrapInputGroupLabel DisplayText="km" />
</BootstrapInputGroup>
<BootstrapInputGroup class="mt-2">
<BootstrapInput @bind-Value="@BindValue" />
<BootstrapInputGroupLabel DisplayText="@StringAt" />
<BootstrapInput @bind-Value="@StringMailServer" />
<Button Icon="fa-solid fa-print" IsOutline="true"></Button>
<Button Icon="fa-solid fa-magnifying-glass" IsOutline="true"></Button>
</BootstrapInputGroup>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
private string BindValue { get; set; } = string.Empty;
private string StringAt { get; set; } = "@";
private string StringMailServer { get; set; } = "163.com";
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
Model = Foo.Generate(LocalizerFoo);
}
}
Add Select
Add Select
component to the InputGroup
Demo
UserName
请选择 ...
北京
上海
请选择 ...
北京
上海
UserName
@inject IStringLocalizer<InputGroupsSelect> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo
<div>
<div class="row g-3">
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="@Localizer["InputGroupsSelectUserName"]" />
<Select TValue="string" Items="@Items"></Select>
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<Select TValue="string" Items="@Items"></Select>
<BootstrapInputGroupLabel DisplayText="@Localizer["InputGroupsSelectUserName"]" />
</BootstrapInputGroup>
</div>
</div>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
private readonly IEnumerable<SelectedItem> Items = new SelectedItem[]
{
new SelectedItem ("", "请选择 ..."),
new SelectedItem ("Beijing", "北京"),
new SelectedItem ("Shanghai", "上海")
};
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
Model = Foo.Generate(LocalizerFoo);
}
}
ValidateForm
Inside ValidateForm
Demo
Normal
Inline
@inject IStringLocalizer<Foo> LocalizerFoo
<div>
<FormInlineSwitch @bind-Value="@FormRowType" class="mb-3"></FormInlineSwitch>
<ValidateForm Model="@Model">
<div class="@GroupFormClassString">
<div class="col-12 col-sm-6">
<BootstrapInputGroupLabel @bind-Value="@Model.Name" required="true" />
<BootstrapInputGroup>
<Display @bind-Value="@Model.Name"></Display>
<BootstrapInputGroupLabel @bind-Value="@Model.Name" />
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroupLabel @bind-Value="@Model.Address" required="true" />
<BootstrapInputGroup>
<Display @bind-Value="@Model.Address"></Display>
<BootstrapInputGroupLabel @bind-Value="@Model.Address" />
</BootstrapInputGroup>
</div>
</div>
</ValidateForm>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
private string? GroupFormClassString => CssBuilder.Default("row g-3")
.AddClass("form-inline", FormRowType == RowType.Inline)
.Build();
private RowType FormRowType { get; set; }
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
Model = Foo.Generate(LocalizerFoo);
}
}
B station related video link
No
交流群