Blazorise TimeInput component

A native time input component build around the <input type="time">.

Examples

Basic

A native time field example with type="time".
<TimeInput TValue="TimeSpan?" />

Binding

Two-way binding

By using bind-* attribute the selected time will be automatically assigned to the member variable.
<TimeInput TValue="TimeSpan?" @bind-Value="@selectedTime" />
@code{
    TimeSpan? selectedTime;
}

Manual event binding

When using the event ValueChanged, you also must define the Value value attribute.
<TimeInput TValue="TimeSpan?" Value="@selectedTime" ValueChanged="@OnValueChanged" />
@code{
    TimeSpan? selectedTime;

    Task OnValueChanged(TimeSpan? Time)
    {
        selectedTime = Time;

        return Task.CompletedTask;
    }
}

Show Picker

If you want to show the default picker that comes with the time input element you can make it by using the ShowPicker() function.

Note: Keep in mind that not all browser will support the ShowPicker() function.

<Field>
    <Button Color="Color.Primary" Clicked="@(() => timeInputRef.ShowPicker())">
        Show Picker
    </Button>
</Field>
<Field>
    <TimeInput @ref="@timeInputRef" TValue="DateTime" />
</Field>
@code {
    TimeInput<DateTime> timeInputRef;
}

Functions

Name Description
ShowPicker() Show a browser picker for the time input.

API

Parameters

Parameter Description TypeDefault
AriaDescribedBy

Gets or sets the aria-describedby attribute value.

Remarks

When set, this value is rendered as-is and overrides help and validation message ids generated by Field and Validation.

string
AriaInvalid

Gets or sets the aria-invalid attribute value.

Remarks

When set, this value is rendered as-is and overrides the validation-derived aria-invalid state.

string
Autofocus

Set's the focus to the component after the rendering is done.

boolfalse
ChildContent

Specifies the content to be rendered inside this TimeInput.

RenderFragmentnull
Classes

Custom CSS class names for component elements.

TClassesnull
Color

Sets the input text color.

ColorColor.Default
Disabled

Add the disabled boolean attribute on an input to prevent user interactions and make it appear lighter.

boolfalse
Feedback

Placeholder for validation messages.

RenderFragmentnull
Intent

Sets the input text intent.

Intentnull
Max

The latest time to accept.

TimeSpan?null
Min

The earliest time to accept.

TimeSpan?null
Pattern

The pattern attribute specifies a regular expression that the input element's value is checked against on form validation.

string
Placeholder

Sets the placeholder for the empty text.

string
Plaintext

Sets the class to remove the default form field styling and preserve the correct margin and padding.

boolfalse
ReadOnly

Add the readonly boolean attribute on an input to prevent modification of the input’s value.

boolfalse
Size

Sets the size of the input control.

Size?null
Step

The step attribute specifies the legal number intervals for seconds or milliseconds in a time field (does not apply for hours or minutes). Example: if step="2", legal numbers could be 0, 2, 4, etc.

Remarks

The step attribute is often used together with the max and min attributes to create a range of legal values.

int?null
Styles

Custom inline styles for component elements.

TStylesnull
TabIndex

If defined, indicates that its element can be focused and can participates in sequential keyboard navigation.

int?null
Value

Gets or sets the value inside the input field.

TValuenull
ValueExpression

Gets or sets an expression that identifies the input value.

Expression<Func<TValue>>null

Events

Event Description Type
Blur

The blur event fires when an element has lost focus.

EventCallback<FocusEventArgs>
CustomValidationValue

Used to provide custom validation value on which the validation will be processed with the Validator handler.

Remarks

Should be used carefully as it's only meant for some special cases when input is used in a wrapper component, like Autocomplete or SelectList.

Func<TValue>
FocusIn

Occurs when the input box gains focus.

EventCallback<FocusEventArgs>
FocusOut

Occurs when the input box loses focus.

EventCallback<FocusEventArgs>
KeyDown

Occurs when a key is pressed down while the control has focus.

EventCallback<KeyboardEventArgs>
KeyPress

Occurs when a key is pressed while the control has focus.

EventCallback<KeyboardEventArgs>
KeyUp

Occurs when a key is released while the control has focus.

EventCallback<KeyboardEventArgs>
OnFocus

Occurs when the input box gains or loses focus.

EventCallback<FocusEventArgs>
ValueChanged

Occurs after value has changed.

EventCallback<TValue>

Methods

Method DescriptionReturnParameters
ShowPicker Show a browser picker for the time input. Task
Select Select all text in the underline component. Taskbool focus
Focus Sets the focus on the underline element. Taskbool scrollToElement
Revalidate Forces the Validation (if any is used) to re-validate with the new custom or internal value. Task
On this page