jakubiszon
jakubiszon

Reputation: 3573

How to assign class attribute to InputDate in blazor?

I want to assign a class attribute to <InputDate /> component. I tried using AdditionalAttributes but its syntax is not clear to me. What I ended up with is this:

<InputDate @bind-Value="Model.Task.TaskDate" @attributes="datePickerAttributes" />

@code {
    private Dictionary<string,object> datePickerAttributes = new Dictionary<string, object>()
    {
        ["class"] = "form-control"
    };
}

It works but looks messy. Is there a more concise way to achieve the same result?

Upvotes: 0

Views: 968

Answers (1)

Mister Magoo
Mister Magoo

Reputation: 8964

You seem to be overthinking things, you want to assign a class - just do that.

<InputDate @bind-Value="Model.Task.TaskDate" class="form-control" />

Upvotes: 3

Related Questions