Skip to content

TimePicker

TimePicker in <huxerui/view.h> edits std::chrono::minutes since midnight. The valid interval is zero inclusive to 24 hours exclusive; this is not an instant, duration editor, or timezone-aware datetime.

#include <huxerui/huxerui.h>
#include <chrono>
using namespace huxerui;
using namespace std::chrono_literals;
[[huxerui::composable]]
View MeetingTime() {
auto time = UseState(std::chrono::minutes{9h});
return TimePicker(time)
.Label("Meeting time")
.Step(15min)
.OnChanged([time](std::chrono::minutes next) { time = next; });
}
  • Construct from std::chrono::minutes or State<std::chrono::minutes>.
  • .Step(minutes) must be positive, at most 60, and divide 60 evenly. The controlled minute value must align with it.
  • .DisabledTimes(predicate) suppresses unavailable user choices without silently rewriting application state.
  • .Label(StringVariant) and .Validation(ValidationResult) provide labeling and feedback.
  • .OnChanged(handler) proposes the next minute value.
  • TimePickerStyle resolves through the theme.

Locale chooses hour-cycle and text direction. Keep scheduling rules and date/timezone conversion in application code; the picker does not infer them from display text.

See DatePicker for the corresponding calendar value.

TimePicker is inline clock-face content. To collect a confirmed value, place it inside a Dialog or BottomSheet with a draft State<std::chrono::minutes> and explicit Apply/Cancel actions. A value such as 9h + 30min always means 09:30 local clock time; choosing a 12-hour locale changes presentation, not the stored number.

DisabledTimes receives std::chrono::minutes and returns true for an unavailable choice. OnChanged receives the same type by value. A step that is zero, exceeds one hour, or does not divide one hour is invalid; invalid or off-step controlled values are not silently repaired. Domain feedback belongs to Validation, independently of disabling choices.

Fields Effect
background, dial_background, border, corner_radii, padding Outer and clock surfaces.
foreground, disabled_foreground, selected_background, selected_foreground, hand Clock text, selection, and hand colors.
field_background, selected_field_background, selected_field_foreground, field_corner_radii Hour/minute field states.
selected_period_background, selected_period_foreground, period_border, period_corner_radii AM/PM group appearance.
header_style, period_style, dial_style, label_style Typography by role.
dial_size, header_height, field_width, separator_width, content_spacing Main layout dimensions.
period_width, period_spacing AM/PM dimensions; the group is omitted in a 24-hour locale.
selection_radius, hand_width Clock marker and hand geometry.
label_spacing, validation_error, validation_text_style, validation_spacing Label and validation feedback.