Blazor and Bootstrap 5 Floating labels

Viewed 492

Using Blazor I migrated to bootstrap 5 and want to use Floating labels with standard Blazor <InputNumber @bind-Value="FooModel.FooValue" />.

I'm trying combinations like:

<div class="form-floating">
    <InputNumber type="number" class="form-control" id="floatingInput" placeholder="name@example.com" @bind-Value="FooModel.FooValue" />
    <label for="floatingInput">Test blazor</label>
</div>

but it's not working. Any ideas?

2 Answers

It works. Which part of it is not working for you? Try @bind-Value="@FooModel.FooValue" instead of @bind-Value="FooModel.FooValue"

Assuming FooModel is the variable name and NOT class name.

Ok, I founded my own bug - FooModel.FooValue was not nullable int type, so on View 0 was displayed as default;

Thanks anyway

Related