Enterprise-level component library based on Bootstrap and Blazor
gitee
version
license
download
repo
commit
build
coverage

Input

Enter characters with the mouse or keyboard

Provides basic text entry components

Demo

You can set the IsAutoFocus whether to automatically get focus, and the components that are last executed when multiple text boxes set auto-focus will get focus

Change the color of the text border by setting Color

Demo

Using OnEnterAsync OnEscAsync callback delegates to respond to the Enter ESC keystrokes

Demo
Basic usage
Press the keyboard Enter or Esc test

Execute @ref.SelectAllTextAsync() method select the all text

Basic usage

Displays the value of variables within the component

Demo
One-way binding

Binding variables within a component, data is automatically synchronized

Demo

when BootstrapInput components turn on bidirectional binding, the Display/DisplayName label value is automatically fetched based on the bound Model property value and appears as a pre-Label, by DisplayText Properties can customize the display of pre-labels, or turn off the display of pre-labels through the ShowLabel property

Custom labels

Set the DisplayText value to custom label

Occupants

The value of DisplayText is displayed when ShowLabel is true, regardless of whether the value is set

Do not occupy seats

The value of DisplayText is not displayed when the ShowLabel is false

Check data validity and prompt automatically based on custom validation rules

Demo

By setting the property type value to password the password input box that is blocked by * after entering text

Demo

In order to support more text box properties this component can be written directly to type='email' type='number' type='phone' and so onhtml5 all property values supported by the new standard, the component does not set the type value using the default type='text'

BootstrapInput component bidirectional binding value is generic, in this case a two-way binding of an int type value

Demo
The binding value: 000

When you set the IsDisabled property value to true, the component suppresses input

Demo

When you set the FormatString property value to yyyy-MM-dd, the component displays a time format of the year and day

Demo
Set up FormatString
Set up Formatter

The BootstrapInput component binds byte[] array and formats it as an example of base64 encoded string

Set up Formatter

Use the BootstrapPassword component

Demo
Basic usage

Use IsTrim="true" to automatically trim white space when entering content

Demo

The front and back spaces in the component will be trimmed when set IsTrim to true

Basic usage
123Tom456

Attributes

Loading...
@page "/inputs"
@inject IStringLocalizer<Inputs> Localizer

<h3>Input</h3>

<h4>Enter characters with the mouse or keyboard</h4>

<DemoBlock Title="Basic usage" Introduction="Provides basic text entry components" Name="Normal">
    <p>You can set the <code>IsAutoFocus</code> whether to automatically get focus, and the components that are last executed when multiple text boxes set auto-focus will get focus</p>
    <div class="row g-3">
        <div class="col-12 col-sm-6">
            <BootstrapInput PlaceHolder="@PlaceHolderText" TValue="string" IsAutoFocus="true" IsSelectAllTextOnFocus="true" ShowLabel="true" DisplayText="Select all on focus" />
        </div>
        <div class="col-12 col-sm-6">
            <BootstrapInput PlaceHolder="@PlaceHolderText" TValue="string" IsSelectAllTextOnEnter="true" ShowLabel="true" DisplayText="Select all on enter" />
        </div>
    </div>

</DemoBlock>

<DemoBlock Title="Color" Introduction="Change the color of the text border by setting <code>Color</code>" Name="Color">
    <div class="row g-3">
        <div class="col-12 col-sm-6">
            <BootstrapInput TValue="string" Color="Color.Primary" />
        </div>
        <div class="col-12 col-sm-6">
            <BootstrapInput TValue="string" Color="Color.Info" />
        </div>
        <div class="col-12 col-sm-6">
            <BootstrapInput TValue="string" Color="Color.Warning" />
        </div>
        <div class="col-12 col-sm-6">
            <BootstrapInput TValue="string" Color="Color.Danger" />
        </div>
        <div class="col-12 col-sm-6">
            <BootstrapInput TValue="string" Color="Color.Secondary" />
        </div>
        <div class="col-12 col-sm-6">
            <BootstrapInput TValue="string" Color="Color.Dark" />
        </div>
    </div>
</DemoBlock>

<DemoBlock Title="Keyboard response" Introduction="Using <code>OnEnterAsync</code> <code>OnEscAsync</code> callback delegates to respond to the <kbd>Enter</kbd> <kbd>ESC</kbd> keystrokes" Name="Keyboard">
    <div class="row g-3">
        <div class="col-auto col-form-label">
            <span>Basic usage</span>
        </div>
        <div class="col-6">
            <BootstrapInput TValue="string" PlaceHolder="@PlaceHolderText" OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync" />
        </div>
        <div class="col-12">
            <div>Press the keyboard <kbd>Enter</kbd> or <kbd>Esc</kbd> test</div>
        </div>
    </div>
    <p>Execute @ref.SelectAllTextAsync() method select the all text</p>
    <div class="row g-3">
        <div class="col-auto col-form-label">
            <span>Basic usage</span>
        </div>
        <div class="col-6">
            <BootstrapInput TValue="string" PlaceHolder="@PlaceHolderText" @ref="Input1" OnEnterAsync="OnEnterSelectAllAsync" />
        </div>
    </div>
    <BlockLogger class="mt-3" @ref="Trace" />
</DemoBlock>

<DemoBlock Title="One-way binding data" Introduction="Displays the value of variables within the component" Name="Placeholder">
    <div class="row g-3">
        <div class="col-auto col-form-label">
            <span>One-way binding</span>
        </div>
        <div class="col-6">
            <BootstrapInput PlaceHolder="@PlaceHolderText" Value="@Model.Name" />
        </div>
    </div>
</DemoBlock>

<DemoBlock Title="Bind data in both directions" Introduction="Binding variables within a component, data is automatically synchronized" Name="Labels">
    <p>when <code>BootstrapInput</code> components turn on bidirectional binding, the <code>Display/DisplayName</code> label value is automatically fetched based on the bound <code>Model</code> property value and appears as a <code>pre-Label</code>, by <code>DisplayText</code> Properties can customize the display of pre-labels, or turn off the display of pre-labels through the <code>ShowLabel</code> property</p>
    <div class="row g-3">
        <Divider Text="Custom labels" />
        <div class="col-12">
            <p>Set the <code>DisplayText</code> value to <b>custom label</b></p>
        </div>
        <div class="col-12">
            <BootstrapInput PlaceHolder="@PlaceHolderText" @bind-Value="@Model.Name" DisplayText="Custom labels" ShowLabel="true" />
        </div>
        <Divider Text="Occupants" />
        <div class="col-12">
            <p>The value of <code>DisplayText</code>  is displayed when <code>ShowLabel</code> is <code>true</code>, regardless of whether the value is set</p>
        </div>
        <div class="col-12">
            <BootstrapInput PlaceHolder="@PlaceHolderText" @bind-Value="@Model.Name" ShowLabel="true" />
        </div>
        <Divider Text="Do not occupy seats" />
        <div class="col-12">
            <p>The value of <code>DisplayText</code> is not displayed when the <code>ShowLabel</code> is <code>false</code></p>
        </div>
        <div class="col-12">
            <BootstrapInput PlaceHolder="@PlaceHolderText" @bind-Value="@Model.Name" />
        </div>
    </div>
</DemoBlock>

<DemoBlock Title="Client valiation" Introduction="Check data validity and prompt automatically based on custom validation rules" Name="ValidateForm">
    <Tips>When using bidirectional binding, you will automatically look for <code>the key</code> value  the resource file with a value of <code>{FieldName}.PlaceHolder</code> the corresponding value as <code>placeholder</code> shows that in this example, the <code>placeholder</code> value is the <code>Name.PlaceHolder</code> key corresponding value in the resource file<code>required</code> non-empty </Tips>
    <ValidateForm Model="@Model">
        <BootstrapInput maxlength="5" @bind-Value="@Model.Name" />
    </ValidateForm>
</DemoBlock>

<DemoBlock Title="The password box" Introduction="By setting the property <code>type</code> value to <code>password</code> the password input box that is blocked by <code>*</code> after entering text" Name="Password">
    <p>In order to support more text box properties this component can be written directly to <code>type='email'</code> <code>type='number'</code> <code>type='phone'</code> and so on<code>html5</code> all property values supported by the new standard, the component does not set the <code>type</code> value using the default <code>type='text'</code></p>
    <BootstrapInput TValue="string" PlaceHolder="@PlaceHolderText" type="password" maxlength="5" style="width: 200px;" />
</DemoBlock>

<DemoBlock Title="Generic binding" Introduction="<code>BootstrapInput</code> component bidirectional binding value is generic, in this case a two-way binding of an int type value" Name="FormatString">
    <div class="row g-3">
        <div class="col-12 col-sm-6">
            <BootstrapInput FormatString="000" step="1" PlaceHolder="@PlaceHolderText" @bind-Value="@Model.Count" />
        </div>
        <div class="col-12 col-sm-6">
            <div class="col-form-label">The binding value: @Model.Count.ToString("000")</div>
        </div>
    </div>
</DemoBlock>

<DemoBlock Title="Disable" Introduction="When you set the <code>IsDisabled</code> property value to <code>true</code>, the component suppresses input" Name="Disabled">
    <BootstrapInput TValue="string" IsDisabled="true" />
</DemoBlock>

<DemoBlock Title="Custom format" Introduction="When you set the <code>FormatString</code> property value to <code>yyyy-MM-dd</code>, the component displays a time format of the year and day" Name="FormatString">
    <div class="row g-3">
        <div class="col-12 col-sm-6 col-form-label">Set up <code class="ms-1">FormatString</code></div>
        <div class="col-12 col-sm-6">
            <BootstrapInput Value="DateTime.Now" FormatString="yyyy-MM-dd" IsDisabled="true" />
        </div>
        <div class="col-12 col-sm-6 col-form-label">Set up <code class="ms-1">Formatter</code></div>
        <div class="col-12 col-sm-6">
            <BootstrapInput Value="DateTime.Now" Formatter="@DateTimeFormatter" IsDisabled="true" />
        </div>
    </div>
    <p class="mt-3">The <code>BootstrapInput</code> component binds <code>byte[]</code> array and formats it as an example of <code>base64</code> encoded string</p>
    <div class="row g-3">
        <div class="col-12 col-sm-6 col-form-label">Set up <code class="ms-1">Formatter</code></div>
        <div class="col-12 col-sm-6">
            <BootstrapInput Value="@ByteArray" Formatter="@ByteArrayFormatter" IsDisabled="true" />
        </div>
    </div>
</DemoBlock>

<DemoBlock Title="The password box" Introduction="Use the <code>BootstrapPassword</code> component" Name="Password2">
    <div class="row g-3">
        <div class="col-auto col-form-label">
            <span>Basic usage</span>
        </div>
        <div class="col-6">
            <BootstrapPassword PlaceHolder="@PlaceHolderText" IsSelectAllTextOnFocus="true" />
        </div>
    </div>
</DemoBlock>

<DemoBlock Title="Trim" Introduction="Use <code>IsTrim="true"</code> to automatically trim white space when entering content" Name="Trim">
    <p>The front and back spaces in the component will be trimmed when set <code>IsTrim</code> to <code>true</code></p>
    <div class="row g-3">
        <div class="col-auto col-form-label">
            <span>Basic usage</span>
        </div>
        <div class="col-6">
            <BootstrapInput @bind-Value="Model.Name" PlaceHolder="@PlaceHolderText" IsTrim="true" />
            <div class="mt-2">123<span>@Model.Name</span>456</div>
        </div>
    </div>
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Common;
using BootstrapBlazor.Shared.Components;

namespace BootstrapBlazor.Shared.Samples;

/// <summary>
/// 
/// </summary>
public partial class Inputs
{
    private string? PlaceHolderText { get; set; }

    private byte[] ByteArray { get; set; } = new byte[] { 0x01, 0x12, 0x34, 0x56 };

    private static string ByteArrayFormatter(byte[] source) => Convert.ToBase64String(source);

    [NotNull]
    private Foo? Model { get; set; }

    private static string DateTimeFormatter(DateTime source) => source.ToString("yyyy-MM-dd");

    [NotNull]
    private BlockLogger? Trace { get; set; }

    [NotNull]
    private BootstrapInput<string>? Input1 { get; set; }

    /// <summary>
    /// 
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        PlaceHolderText = Localizer["PlaceHolder"];
        Model = new Foo() { Name = Localizer["TestName"] };
    }

    private Task OnEnterAsync(string val)
    {
        Trace.Log($"Enter {Localizer["Log"]}: {val}");
        return Task.CompletedTask;
    }

    private Task OnEscAsync(string val)
    {
        Trace.Log($"Esc {Localizer["Log"]}: {val}");
        return Task.CompletedTask;
    }

    private async Task OnEnterSelectAllAsync(string val)
    {
        Trace.Log($"Enter call SelectAllText {Localizer["Log"]}: {val}");
        await Input1.SelectAllTextAsync();
    }

    private IEnumerable<AttributeItem> GetAttributes() => new[]
    {
        new AttributeItem() {
            Name = "ChildContent",
            Description = Localizer["Att1"],
            Type = "RenderFragment",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "ShowLabel",
            Description = Localizer["Att2"],
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem() {
            Name = "DisplayText",
            Description = Localizer["Att3"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "Color",
            Description = Localizer["Att4"],
            Type = "Color",
            ValueList = "Primary / Secondary / Success / Danger / Warning / Info / Dark",
            DefaultValue = "Primary"
        },
        new AttributeItem() {
            Name = "FormatString",
            Description = Localizer["Att5"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "Formatter",
            Description = Localizer["Att6"],
            Type = "RenderFragment<TItem>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem()
        {
            Name = "type",
            Description = Localizer["Att7"],
            Type = "string",
            ValueList = "text / number / email / url / password",
            DefaultValue = "text"
        },
        new AttributeItem() {
            Name = "OnEnterAsync",
            Description = Localizer["Att8"],
            Type = "Func<TValue, Task>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "OnEscAsync",
            Description = Localizer["Att9"],
            Type = "Func<TValue, Task>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem()
        {
            Name = "IsDisabled",
            Description = Localizer["Att10"],
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = "IsAutoFocus",
            Description = Localizer["Att11"],
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = nameof(BootstrapInput<string>.IsSelectAllTextOnFocus),
            Description = Localizer[nameof(BootstrapInput<string>.IsSelectAllTextOnFocus)].Value,
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = nameof(BootstrapInput<string>.IsTrim),
            Description = Localizer[nameof(BootstrapInput<string>.IsTrim)].Value,
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = nameof(BootstrapInput<string>.ValidateRules),
            Description = Localizer[nameof(BootstrapInput<string>.ValidateRules)].Value,
            Type = "List<IValidator>",
            ValueList = " — ",
            DefaultValue = " — "
        }
    };
}

B 站相关视频链接

暂无

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
Themes
Bootstrap
Motronic
Ant Design (完善中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload
Seems like the connection with the server has been lost. It can be due to poor or broken network. Please hang on while we're trying to reconnect...
Oh snap! Failed to reconnect with the server. This is typically caused by a longer network outage, or if the server has been taken down. You can try to reconnect, but if that does not work, you need to reload the page.
Oh man! The server rejected the attempt to reconnect. The only option now is to reload the page, but be prepared that it won't work, since this is typically caused by a failure on the server.
Bootstrap Blazor 组件库 更新到 6.6.0

首先感谢您对本套组件的关注,本目前本套组件已经拥有超过 120 个组件,本组件是基于 Bootstrap 风格的 Blazor 企业级组件库,提供如布局、导航、表单、数据、通知、图标、语音等几大类通用组件,每一个组件都经过静心设计,具有模块化、响应式和优秀的性能。从更多实际场景出发,满足多种场景的需求,极大的减少开发者时间成本,大大缩短开发周期,大幅提高开发效率,并提供了一套 通用权限管理系统 示例工程。Bootstrap Blazor 产品是由一支专业的全职技术团队进行维护,高效的响应速度,多元化的解决方案,长期提供支持,并提供企业级支持。目前已在多家知名国企内部使用,项目最高在线 1200 人稳定运行。右侧为国内人数最多的中文 Blazor QQ 社区二维码,欢迎扫描加群。

组件更新到 6.6.0 更新日志 [传送门] 如果组件给您带来了方便,请您帮忙给项目点亮 Star github gitee

QQGroup
QQ 795206915