Form controls
DInput, DCheckbox, DSwitch, DRadio and
DSelect build on Blazor's InputBase<TValue>: they support
@bind-Value and integrate with EditForm /
DataAnnotationsValidator out of the box. Invalid fields automatically get
daisyUI's input-error / select-error styling.
EditForm with validation— DataAnnotations validation, daisyUI error styling, and a success alert on valid submit
<EditForm Model="_model" OnValidSubmit="HandleValid" class="flex flex-col gap-4">
<DataAnnotationsValidator />
<div class="flex flex-col gap-1">
<DInput @bind-Value="_model.Name" Label="Name" Placeholder="Jane Doe" />
<div class="text-[var(--color-error)] text-sm"><ValidationMessage For="() => _model.Name" /></div>
</div>
<div class="flex flex-col gap-1">
<DInput @bind-Value="_model.Email" Label="Email" Type="email" Placeholder="jane@example.com" />
<div class="text-[var(--color-error)] text-sm"><ValidationMessage For="() => _model.Email" /></div>
</div>
<DInput @bind-Value="_model.Password" Label="Password" Type="password" Placeholder="Secret" Size="DaisySize.Small" />
<DSelect TValue="string" @bind-Value="_model.Fruit" Label="Favourite fruit" Items="_fruits" Placeholder="(choose one)" />
<fieldset class="flex flex-col gap-1">
<legend class="text-sm font-medium mb-1">Plan</legend>
<DRadio TValue="string" @bind-Value="_model.Plan" GroupName="plan-demo" CheckValue="@("free")" Label="Free" />
<DRadio TValue="string" @bind-Value="_model.Plan" GroupName="plan-demo" CheckValue="@("pro")" Label="Pro" />
<DRadio TValue="string" @bind-Value="_model.Plan" GroupName="plan-demo" CheckValue="@("enterprise")" Label="Enterprise" />
</fieldset>
<DCheckbox @bind-Value="_model.Subscribe" Label="Subscribe to the newsletter" />
<DSwitch @bind-Value="_model.TermsAccepted" Label="Accept the terms" Size="DaisySize.Small" />
<div class="flex items-center gap-3">
<DButton Type="submit" Color="DaisyColor.Primary">Save</DButton>
@if (_submittedAt is not null)
{
<DAlert Color="DaisyColor.Success" Variant="DaisyVariant.Soft">
<ChildContent>Submitted at @_submittedAt.Value.ToString("HH:mm:ss")</ChildContent>
</DAlert>
}
</div>
</EditForm>
@code {
private readonly string[] _fruits = ["Apple", "Banana", "Mango"];
private readonly DemoModel _model = new();
private DateTime? _submittedAt;
private void HandleValid() => _submittedAt = DateTime.Now;
private sealed class DemoModel
{
[Required(ErrorMessage = "Name is required.")]
public string? Name { get; set; }
[EmailAddress(ErrorMessage = "Not a valid email address.")]
public string? Email { get; set; }
public string? Password { get; set; }
public string? Fruit { get; set; } = "Banana";
public string? Plan { get; set; } = "pro";
public bool Subscribe { get; set; } = true;
public bool TermsAccepted { get; set; }
}
}API
DInput
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Type | string | text | — | The HTML input type (text, password, email, number, date, ...). Default: text. |
| Placeholder | string | — | — | Placeholder text shown inside the input when empty. |
| Label | string | — | — | Optional label rendered above the input. |
| Size | DaisySize | Medium | — | Sizes the input via daisyUI (input-xs, input-sm, input-lg). ExtraSmallSmallMediumLargeExtraLarge |
| Disabled | bool | False | — | Disables the input. |
| Validator | bool | False | — | Adds daisyUI's validator class so a sibling DValidator hint can appear purely via CSS ( :user-invalid ) — no Blazor validation required. |
| Class | string | — | — | — |
| Style | string | — | — | — |
| Value | string | — | @bind-Value | — |
| ValueExpression | Expression<Func<string>> | — | — | — |
| DisplayName | string | — | — | — |
DCheckbox
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Label | string | — | — | Optional label rendered next to the checkbox. |
| Disabled | bool | False | — | Disables the checkbox. |
| Size | DaisySize | Medium | — | Size via daisyUI (checkbox-xs/sm/lg). ExtraSmallSmallMediumLargeExtraLarge |
| Class | string | — | — | — |
| Style | string | — | — | — |
| Value | bool | False | @bind-Value | — |
| ValueExpression | Expression<Func<bool>> | — | — | — |
| DisplayName | string | — | — | — |
DSwitchA daisyUI switch bound to a Boolean via @bind-Value . Works standalone or inside an EditForm (shows input -style validation via EditContext).
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Label | string | — | — | Optional label rendered next to the checkbox. |
| Disabled | bool | False | — | Disables the checkbox. |
| Size | DaisySize | Medium | — | Size via daisyUI (checkbox-xs/sm/lg). ExtraSmallSmallMediumLargeExtraLarge |
| Class | string | — | — | — |
| Style | string | — | — | — |
| Value | bool | False | @bind-Value | — |
| ValueExpression | Expression<Func<bool>> | — | — | — |
| DisplayName | string | — | — | — |
DRadio
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| CheckValue | string | — | — | The value this radio represents. The radio is checked when the bound value equals it. |
| GroupName | string | — | — | HTML radio group name; radios sharing a name are mutually exclusive. |
| Label | string | — | — | Optional label rendered next to the radio. |
| Disabled | bool | False | — | Disables the radio. |
| Size | DaisySize | Medium | — | Size via daisyUI (radio-xs/sm/lg). ExtraSmallSmallMediumLargeExtraLarge |
| Class | string | — | — | — |
| Style | string | — | — | — |
| Value | string | — | @bind-Value | — |
| ValueExpression | Expression<Func<string>> | — | — | — |
| DisplayName | string | — | — | — |
DSelect
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Items | IEnumerable<string> | — | — | The items to render as options. |
| ItemText | Func<string, string> | — | — | Optional text projection for each item. Defaults to ToString() . |
| Placeholder | string | — | — | Optional placeholder option (empty value) shown first. |
| Label | string | — | — | Optional label rendered above the select. |
| Disabled | bool | False | — | Disables the select. |
| Size | DaisySize | Medium | — | Size via daisyUI (select-xs/sm/lg). ExtraSmallSmallMediumLargeExtraLarge |
| Class | string | — | — | — |
| Style | string | — | — | — |
| Value | string | — | @bind-Value | — |
| ValueExpression | Expression<Func<string>> | — | — | — |
| DisplayName | string | — | — | — |
DButton
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Type | string | button | — | The native type attribute: button , submit or reset . |
| Color | DaisyColor | Default | — | Contextual color (e.g. btn-primary , btn-ghost ); Default emits no class. DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| Variant | DaisyVariant | Default | — | Style variant (e.g. btn-outline , btn-soft ); Default emits no class. DefaultOutlineDashSoftLink |
| Size | DaisySize | Medium | — | Size (e.g. btn-xs , btn-lg ); Medium emits no class. ExtraSmallSmallMediumLargeExtraLarge |
| Disabled | bool | False | — | Disables the button (native disabled ). |
| IconStart | DaisyIcon | — | — | Icon rendered before the button content (daisy's btn gap handles spacing). |
| IconEnd | DaisyIcon | — | — | Icon rendered after the button content. |
| IconSize | DaisySize? | — | — | Icon size; defaults to the button Size when null . ExtraSmallSmallMediumLargeExtraLarge |
| Shape | DaisyButtonShape | Default | — | btn-square / btn-circle — use with an icon and no text for icon-only buttons. DefaultSquareCircle |
| Wide | bool | False | — | btn-wide : widens the button to width:100% of its container, capped at 16rem . When both Wide and Block are set, btn-block wins on width (it is declared later in daisyUI's cascade at equal specificity) and the button fills its container, still capped at 16rem by btn-wide 's max-width . |
| Block | bool | False | — | btn-block : the button fills the full width of its container ( width:100% ). When both Block and Wide are set, btn-block wins on width (it is declared later in daisyUI's cascade at equal specificity). |
| ChildContent | RenderFragment | — | — | The button's inner text and content. |
| OnClick | EventCallback<MouseEventArgs> | — | — | Invoked when the button is clicked. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DAlert
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Color | DaisyColor | Default | — | Contextual color (e.g. alert-info , alert-success ); Default emits no class. DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| Variant | DaisyVariant | Default | — | Style variant (e.g. alert-outline , alert-soft ); Default emits no class. DefaultOutlineDashSoftLink |
| Icon | DaisyIcon | — | — | Optional leading icon (e.g. DaisyIcons.Warning or a CDN icon via DaisyIcon.FromUrl ). |
| IconSize | DaisySize | Large | — | Icon size for Icon . ExtraSmallSmallMediumLargeExtraLarge |
| ChildContent | RenderFragment | — | — | The alert's message content. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |