BzInput / BzSelect

فرم و اینپوت ها

اینپوت متن، دراپ دون، چک باکس، سوییچ و ریدیو باتن.

اینپوت متن

با TValue نوع مقدار را مشخص کن و با bind-Value وصلش کن.

name= | family=

razor
@using BzCore.Components.Input

<BzInput TValue="string" @bind-Value="_name" Label="نام"
         Clearable Placeholder="نام خود را بنویسید" />

<BzInput TValue="string" @bind-Value="_family" Label="نام خانوادگی" Clearable />

<p>name=@_name | family=@_family</p>

@code {
    private string _name = "";
    private string _family = "";
}

@*
Handy extras:
    UpdateTrigger="BzUpdateTrigger.OnInput"   update on every keystroke
    CharFilter="BzCharFilter.NumberOnly"      digits only
    Mode="BzInputMode.Mask" Mask="###-###"   masked input
    MaxLength / StartIcon / EndIcon / Disabled
*@
انتخاب گر

گزینه ها را با BzOption بده: مقدار، برچسب و آیکن اختیاری.

city=

razor
@using BzCore.Components.Form

<BzSelect TValue="string" @bind-Value="_city" Label="شهر"
          Items="_cities" Clearable Placeholder="یک شهر" />

<p>city=@_city</p>

@code {
    private string _city = "";

    // BzOption<T>(value, label, icon?)
    private List<BzOption<string>> _cities = new()
    {
        new("tehran", "تهران"),
        new("mashhad", "مشهد"),
        new("isfahan", "اصفهان"),
    };
}
چک باکس و سوییچ

هر دو به یک bool وصل میشن. Shape شکل چک باکس را عوض میکنه.

agree=False | news=True | dark=False

razor
@using BzCore.Components.Form
@using BzCore.Enums

<BzCheckbox @bind-Value="_agree" Label="موافقم" Color="BzColor.Success" />

<BzCheckbox @bind-Value="_news" Label="خبرنامه"
            Shape="BzCheckShape.Rounded" Color="BzColor.Info" />

<BzSwitch @bind-Value="_dark" Label="حالت تیره" Color="BzColor.Primary" />

<p>agree=@_agree | news=@_news | dark=@_dark</p>

@code {
    private bool _agree;
    private bool _news = true;
    private bool _dark;
}
ریدیو

با Card هر گزینه به یک کارت قابل کلیک تبدیل میشه.

plan=pro

razor
@using BzCore.Components.Form
@using BzCore.Enums

<BzRadioGroup TValue="string" @bind-Value="_plan"
              Orientation="BzOrientation.Horizontal"
              Color="BzColor.Success"
              Card
              Items="_plans" />

<p>plan=@_plan</p>

@code {
    private string _plan = "pro";

    private List<BzOption<string>> _plans = new()
    {
        new("free", "Free"),
        new("pro",  "Pro"),
        new("team", "Team"),
    };
}