There are existing components in Blazor that makes it to get different types of
user input, like strings, numbers, and date. But what about time?
The problem
There is support for just time in HTML, but it is not supported by all browsers.
And it does not automatically map to a .NET type like DateTime or integer.
The solution
My solution was to create this little Blazor component below.
Time picker component
Note that it has support for using native input time component it you prefer to
use that (but I do not recommend this). The data type is integer, the number of
seconds counted from midnight. Here is some test code you could use to test the
component:
Test code
With the default controls it looks like this:
And this is with the native controls:
Summary
This is a basic component. It formats the time as a 24-hour clock and it does
not let you select the second on the time. But all these are easy to tweaks if
you need to.
In my next post I show you could create a date
and time picker component based on this time picker component.