Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Value and onChange

The picker is controlled: value holds a 24-hour HH:mm string, and onChange gives back the new one.

A controlled time field
value in, onChange out. The value is always a 24-hour HH:mm string: store and compare that, never a localised label.

HH:mm: 14:30

Show code
<app-time-picker label="Schedule time" name="scheduleTime" value="14:30" />

Min and max

Keep the choice inside a window with min and max, so an out-of-range time is shown as an error.

Restrict to a valid window
Both bounds are HH:mm strings. Prefer this over accepting any time and rejecting it afterwards.

Business hours only (09:00 to 17:00). Times outside the window can't be picked.

Show code
<app-time-picker label="Meeting time" name="meetingTime" value="14:30" min="09:00" max="17:00" />

Step

Set step in minutes to match the schedule, such as 15 minutes for bookings.

Different step values
30 minutes (default) suits most schedules; 15 minutes for fine-grained bookings.
Show code
<app-time-picker label="30-minute step" name="step30" />
<app-time-picker label="15-minute step" name="step15" step="15" />

Typing and keyboard

People can type a time and commit it with Enter, or step through the columns with the arrow keys.

Minute-exact times without scrolling
step 1 gives a 60-entry minute column, not one entry per minute of the day. On a phone, tap the clock to pick; tap the text to type.
Show code
<app-time-picker label="Check-in time" name="checkIn" format="12" step="1" />

Display format

Choose 12-hour or 24-hour display for people; the value always stores as 24-hour HH:mm.

Display formats
format is display-only. The value always stores and posts as 24-hour HH:mm.
Show code
<app-time-picker label="24-hour" name="fmt24" format="24" />
<app-time-picker label="12-hour" name="fmt12" format="12" />

Placeholder

Use a placeholder to say what the empty field expects, beside a label rather than in place of one.

Custom empty-state text
The default is "Select time"; override it to fit the field.
Show code
<app-time-picker label="Meeting time" name="meetingTime" placeholder="Pick a meeting time" />

Size and width

Match the time field to the inputs beside it, and resize it only when its content needs room.

Three heights
The value and clock icon scale with the trigger.
Show code
<app-time-picker label="Small" size="ControlSize.Sm" />
<app-time-picker label="Medium" />
<app-time-picker label="Large" size="ControlSize.Lg" />
Sizing the field
time-w-full restores the full-column width that aligns with other form fields.
Show code
<app-time-picker label="Small" class="time-w-sm" />
<app-time-picker label="Large" class="time-w-lg" />
<app-time-picker label="Full" class="time-w-full" />

Every option

Every value of every prop, one cell each.

value: the controlled time

value="14:30"
value="" (no time chosen)

defaultValue: starting time, uncontrolled

value="09:30" (React: defaultValue)

label: the label above the field

label="Meeting time"

name: the posted field name

name="meetingTime" (posted with the form, no visible change)

id: the control's id

id="meeting-time" (no visible change)

ariaLabel: the accessible name

aria-label="Meeting time" (React: ariaLabel; screen readers only)

required: the required mark

required="true"

optional: (optional) after the label

optional="true"

optionalLabel: the text for (optional)

optional="true" optional-label="(facultatif)"

helperText: help under the field

helper-text="24-hour format"
24-hour format

error: an error message

error="A time is required"
A time is required

help: info tip beside the label

help="Times are in IST"

helpLabel: the info tip's accessible name

help="Times are in IST" help-label="About meeting times"

min and max: the selectable window

min="09:00" max="17:00"
min="00:00" max="12:00" (morning only)

step: minutes between choices

step="1"
step="15"
step="30" (default)
step="60"

format: 24 or 12 hour display

format="24" (default)
format="12"

placeholder: text while no time is chosen

placeholder="Select time" (default)
placeholder="Pick a meeting time"

size: every height tier

size="md" (default)
size="sm"
size="lg"

disabled: locks the field

disabled="true"

readOnly: shows the value, blocks editing

read-only="true"

loading: busy state, blocks input

loading="true"

className: a class on the control

input-class="time-w-full"

fieldClassName: a class on the wrapping field

class="mb-3" (React: fieldClassName)

onChange: the callback

change event: fires when a time is committed (React: onChange)

Guidance

What to do, and what to avoid.

Use it when

  • Capturing a time of day: a meeting time, a schedule slot, a booking time.
  • You need one consistent time picker across every browser and both surfaces.
  • Restricting selection to a valid window with min / max.
  • Controlling step granularity (1, 15, 30, or 60 minutes).

Reach for something else when

  • You need both a date and a time. → a date picker next to a time picker
  • The value is free text, not a time. → AppInput
  • You are picking from a fixed list of labels. → AppSelect

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

24 12
(default) md sm lg
React, generated from the controls
<AppTimePicker label="Meeting time" name="meetingTime" value="14:30" onChange={setValue} size="md" />
Razor, the same props
<app-time-picker label="Meeting time" name="meetingTime" value="14:30" />

20 props. The 5 most used come first.

Used on most screens 5 props

PropTypeDefaultDescription
labeldefault - string - The label above the field.
valuedefault - string - The time as 24-hour "HH:mm" text, which is also the wire format.
requireddefault false bool false Marks the field required and shows the required mark beside the label.
helper-textdefault - string - Help text under the field.
errordefault - string - An error message. It replaces the helper text and marks the field invalid.

Less common 15 props

PropTypeDefaultDescription
namedefault - string - The field name the time posts under.
mindefault - string - The earliest time that can be picked, as "HH:mm".
maxdefault - string - The latest time that can be picked, as "HH:mm".
stepdefault 30 number 30 The minutes between choices. The control uses 30 when this is unset.
formatdefault 24 12 | 24 24 The display format, 12 or 24 hour. The wire value stays 24 hour.
placeholderdefault Select time string Select time The text shown while no time is chosen.
optionaldefault false bool false Ends the label with (optional) when the field is not required. Required wins when both are set.
optional-labeldefault (optional) string (optional) Replaces the built-in English text, for other languages.
helpdefault - string - Info-tip text shown beside the label.
help-labeldefault More information string More information The accessible name of the info-tip button.
sizedefault - sm | md | lg - The control height tier, matching AppInput; leave unset for the default height.
disableddefault false bool false Locks the field.
read-onlydefault false bool false Shows the value but blocks editing. The value still posts.
loadingdefault false bool false Shows a busy state and blocks input while data loads.
input-classdefault - string - Extra classes on the control itself. The plain class attribute merges onto the field wrapper instead.

Screen reader

4 notes
  • The trigger is named by ariaLabel, or by a text label when there is none.
  • An error sets aria-invalid and points aria-describedby at the error text, or at the helper text when there is no error.
  • The field carries the required attribute as well as the visible required mark.
  • The info tip beside the label is named by helpLabel.