Skip to content

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.

Time & selection

Which parts of the time the dial offers and how: the 12- and 24-hour faces, the seconds, the edit modes and views, the steps and the selectable range.

Time format

TimeFormat chooses the face. TwentyFourHours (the default) draws a double ring - 13 to 00 on the outside, 01 to 12 on the inside - and the pointer picks the ring it is closest to. TwelveHours draws a single 1 to 12 ring and adds the AM/PM pair to the toolbar, whose labels come from the culture of the picker. AmPmInClock moves that pair under the clock as a segmented control instead, which is what keeps the toolbar legible when the seconds are shown too; it means nothing on a 24-hour face. On an empty 12-hour picker the dial opens on the half that has something to offer, so a range that starts in the afternoon does not greet you with twelve dimmed numbers.

The face only changes how the hour is shown and picked: the value is the same TimeSpan of the day either way (21:45 is 09:45 PM), and the hour predicates and bounds are always given in 0-23. The 12-hour ring shows the half of the day the value is in; pressing AM or PM moves the hour by twelve, and where the constraints rule that hour out it lands on the first hour of the other half that is allowed. The default ValueFormat follows the face, so the field writes the time with a designator on a 12-hour picker and without one on a 24-hour picker.

Select hour
131415161718192021222300010203040506070809101112


Select hour
123456789101112


Select hour
123456789101112

Seconds

ShowSeconds adds a third part: a second ring the dial moves on to after the minute, a third read-out in the toolbar, and the seconds kept in the value instead of zeroed. SecondStep and AllowedSeconds narrow it exactly as their minute counterparts do (see Steps and Selectable range), and the default ValueFormat grows a seconds part with it - a ValueFormat of your own is used as given, so it needs an ss to show them. A picker left without the seconds still carries the ones a bound value came with - it simply never offers a way to change them - and the OnlySeconds edit mode brings the second ring along without ShowSeconds.

Select hour
131415161718192021222300010203040506070809101112


Select hour
131415161718192021222300010203040506070809101112


Selected time: 14:05:30

Edit mode & views

EditMode decides which parts of the time the dial offers. Normal edits all of them and settles onto the next one as soon as the current one is picked, while OnlyHours, OnlyMinutes and OnlySeconds pin the dial to a single part and leave the rest as it is - including the AM/PM pair, which is shown so the read-out can be placed in the day but is not offered where the hour is not a part being edited. StartView chooses which part an opening picker lands on in Normal mode, View reports the one it is on, SwitchView moves it from code, and OnViewChange reports every switch - including the automatic one after a pick.

In a single-part mode the toolbar shows the whole time as text instead of a button per part (styled through the HourMinuteText slot), and OnlySeconds brings the second ring along whether or not ShowSeconds is set. The edit mode always wins over the view: StartView is only read in Normal mode, a Second start view on a picker without the seconds falls back to Hour, and SwitchView - like a press on a toolbar part - does nothing for a part the picker does not edit. Every opening of the callout starts the dial over on its start view, and changing EditMode moves it there at once. The automatic move only follows a pick that was accepted: a press on a dimmed number, or Enter on a part with no value yet, leaves the dial where it is.

Select hour
09:30
131415161718192021222300010203040506070809101112


Select minute
09:30
000510152025303540455055


Select second
09:30:15
000510152025303540455055


Select minute
000510152025303540455055

Last view change: -

Steps

MinuteStep and HourStep set the granularity the dial and the arrow keys move in. A step lays a grid over its range that the pick snaps to, which is what turns the face into a five-minute or quarter-hour picker, and dims the numbers in between so a value the picker does not accept is never offered. A press on a dimmed number changes nothing and leaves the dial where it is. The grid starts at the matching part of MinTime, and at midnight or the top of the hour where there is none, so a picker whose range begins at 09:07 can still be set to 09:07.

All three steps default to 1, and a value below 1 is treated as 1. A step is the granularity of the dial, not a rule about which times exist: a bound value that is off the grid is shown as it is, with the hand resting between two marks, and a time typed into the field is not held to it either. Use AllowedMinutes and its siblings (see Selectable range) where an off-grid time must also fail validation.

Select hour
131415161718192021222300010203040506070809101112


Select hour
131415161718192021222300010203040506070809101112


Select hour
131415161718192021222300010203040506070809101112

Selectable range

MinTime and MaxTime bound what can be picked: the hours outside the range are dimmed, and inside the boundary hours only the minutes still within it stay selectable. AllowedHours, AllowedMinutes and AllowedSeconds add an arbitrary rule on top of that. The pointer refuses a dimmed number, the arrow keys step over it, and a time typed outside the range fails validation with its own OutOfRangeErrorMessage rather than the message an unreadable one gets. DisablePast and DisableFuture bound the range by the current time exactly as a MinTime or a MaxTime of now would; where both apply, the narrower of the two wins. The pair is a range inside one day and does not wrap past midnight - a window that does, such as a night shift, is a job for AllowedHours.

The edges, in detail:
  • The predicates receive the hour of the day in 0-23 whatever the face, and the minute or the second in 0-59. Returning false for every value leaves nothing to pick.
  • A MinTime later than the MaxTime leaves nothing selectable, and a bound outside of a day is clamped into it first - a negative one to 00:00, one of a day or more to the end of the day.
  • Moving the hour pulls a minute (and a second) that the new hour puts out of range to the nearest one still inside it: with a range starting at 08:30, going from 09:15 to the 8 lands on 08:30.
  • DisablePast and DisableFuture read the clock of the device the picker runs on, to the precision the dial shows, so the minute that is running can still be picked; the bound is read again on every render rather than fixed when the picker appears.
  • The bounds and predicates restrict what can be picked and typed, not what is bound: a value set from code outside of them is still shown.

Select hour
131415161718192021222300010203040506070809101112


Select hour
131415161718192021222300010203040506070809101112


Select hour
131415161718192021222300010203040506070809101112


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.