Pickers
CircularTimePicker
Bit.BlazorUI
A BitCircularTimePicker picks a single time from an analog clock dial: an hour ring the pointer snaps to, then a minute ring and an optional second ring, with an AM/PM pair in 12-hour mode. It can be driven with a pointer or entirely from the keyboard, restricted to a range or a step, edited as text, laid out portrait or landscape, and rendered either inline or in a callout that becomes a sheet on small screens.
Accessibility, validation & events
The keyboard and screen-reader support, validation and its messages, and the events.
Keyboard & accessibility
The dial is a listbox whose options are the numbers of the current view, so a screen reader reads out what
the pointer rests on, and the whole time can be set without ever touching the clock:
- Enter, Space, ↓ or ↑ on the field opens the picker and puts the focus on the dial - only the arrows on a field made editable by AllowTextInput, which keeps the focus for typing. Esc closes it from anywhere inside it and puts the focus back on the field.
- Tab and Shift + Tab inside the callout cycle through the toolbar, the dial, the buttons and anything the templates put there, without leaving it. The focus moving off both the field and the callout - a Tab out of an editable field - closes the picker rather than stranding it behind the overlay, and a click on the overlay closes it too.
- ↑ / → and ↓ / ← move the pointer by one step, PageUp / PageDown by five steps, stepping over the values the constraints rule out and wrapping around the face. On an empty picker the first press lands on 00, or on the nearest allowed value from there in the direction pressed; with a StartingValue it steps from that time instead.
- Home and End jump to the first and the last selectable value.
- Digits type the value: 4 5 within a second lands on 45; a digit that would take the number past what the ring holds starts a new one. On a 12-hour dial a typed hour stays in the half of the day shown, and A and P switch the half.
- Enter or Space settles the current view - moving on to the next part, and closing an AutoClose picker once the time is complete.
- Shift + the mouse wheel over the focused dial moves it by one step as well. Both conditions keep an ordinary scroll of the page from changing the time; NoMouseWheel turns it off altogether and InvertMouseWheel reverses it.
CalloutAriaLabel names the dialog, HourButtonTitle, MinuteButtonTitle and
SecondButtonTitle name the toolbar buttons and the dial in each view (their defaults are the
English "Clock", "Select hour", "Select minute" and "Select second", so set them on a page in another
language), AutoFocus puts the focus on the field as the page renders - on the dial of a
standalone picker - and TabIndex reaches the dial as well as the field. Values
the constraints rule out are marked aria-disabled rather than merely dimmed, and a live region
announces every move of the dial - the part it switches to, and the value it lands on where no number of
the face stands for it, so a step of a single minute is never made in silence. In the toolbar the part
the dial is on carries a rule under it rather than the other two being dimmed, so which one is being
edited never rests on a difference of contrast.
Meeting hour
123456789101112
Validation
Inside an EditForm the picker is an ordinary form input: it registers with the EditContext,
turns red and gets aria-invalid when its field has messages. Text is the only way a time the dial
itself refuses can reach it, and the three ways it can be wrong get three messages of their own -
InvalidErrorMessage for one that cannot be read, OutOfRangeErrorMessage for one outside
MinTime / MaxTime, and DisallowedTimeErrorMessage for one the Allowed*
predicates rule out. The steps are the one constraint typed text is not held to. A Standalone
picker has no field to redden, so the rule is drawn around the dial instead, and the dial is what
carries aria-required and aria-invalid.
Left unset, the three messages read "The field field is not valid.", "... is out of the allowed
range." and "... is not an allowed time.", where field is the DisplayName of the picker or
else the name of the bound property. These messages come from the picker; whether a value is required
at all comes from the model, here a [Required] attribute on its TimeSpan? property. The
text is checked as it is typed, so a time half written shows the unreadable-time message until it is
complete. NoValidate keeps the picker out of the EditContext validation altogether.
Type ab:cd, 07:00 and 09:10 into the field below to see each of the three messages.
A standalone picker in the same form. Submit it empty to see the rule around the dial.
Events
OnSelectTime fires for every change the dial makes, OnChange for every change of the value
itself, OnClear for the clear button emptying it, OnOpen and OnClose follow the
callout, OnViewChange follows the dial between the parts of the time, and OnClick,
OnFocusIn and OnFocusOut follow the field.
- OnSelectTime receives the new TimeSpan? for every change the picker itself makes: a pick or drag on the dial, a key, the AM/PM pair, the now and clear buttons (clear passes null) and each keystroke of typed text. OnChange fires whenever the value changes, whatever changed it.
- OnClick is a click on the field, raised after the callout has opened; opening it through OpenCallout or IsOpen raises OnOpen alone.
- OnViewChange passes the BitCircularTimePickerView the dial moved to, and fires for the automatic move after a pick, a press on a toolbar part and SwitchView alike.
- OnFocus (not shown) fires when the input itself takes the focus, while OnFocusIn bubbles from it. A standalone picker has no field, so these and OnClick do not fire on it.
- None of these callbacks can be set through BitParams; they are written on each picker.
Select hour
131415161718192021222300010203040506070809101112
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.