Time Picker
Interactive time selection trigger field and scroll-wheel dialog modal supporting 12-hour AM/PM formats, custom minute intervals, and validation states
The UX4G Time Picker component provides a standardized time selection input for citizens scheduling public service appointments, grievance hearings, passport slots, and administrative verification visits.
Key Capabilities
- Form Input Trigger: Clean outlined input container displaying the selected time formatted in 12-hour AM/PM notation with trailing clock icon (
AccessTime). - Scroll-Wheel Modal Dialog: Integrated
Ux4gTimePickerDialogfeaturing smooth snap-fling vertical wheels for hours (01to12) and minutes (00to59), plus an AM/PM toggle selector. - Custom Minute Intervals: Configurable step increments via
minuteInterval(e.g.,1,5,15, or30minute slots). - Labels & Required Indicators: Form label support with mandatory asterisk (
*) and descriptive helper captions. - Dual Type Support: Overloaded composables supporting both
Ux4gTimeOfDayand standardjava.time.LocalTime.
Import from com.ux4g.designsystemv1.components.Ux4gTimePicker.
Interactive Previews
1. Time Picker Input Field (Ux4gTimePicker)
Outlined time selection trigger field displaying placeholder or chosen time with trailing clock icon.

2. Time Picker Dialog Modal (Auto-Opened on Click)
When a citizen clicks on the time picker input field, the interactive scroll-wheel time picker dialog modal opens automatically to allow hour, minute, and AM/PM selection:

Modal dialog view with hour (HH) and minute (MM) scroll wheels, AM/PM selector toggle, and Done / Cancel action buttons.
Kotlin Usage
1. Appointment Scheduling with 12-Hour AM/PM Format
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.Ux4gTimeOfDay
import com.ux4g.designsystemv1.components.Ux4gTimePicker
@Composable
fun AppointmentSlotBooking() {
var appointmentTime by remember { mutableStateOf<Ux4gTimeOfDay?>(Ux4gTimeOfDay(10, 30)) }
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Ux4gTimePicker(
selectedTime = appointmentTime,
onTimeSelected = { appointmentTime = it },
label = "Appointment Time",
isRequired = true,
minuteInterval = 15,
placeholder = "Choose a time slot",
description = "Appointments are scheduled in 15-minute intervals"
)
}
}2. Using Standard java.time.LocalTime
import androidx.compose.runtime.*
import com.ux4g.designsystemv1.components.Ux4gTimePicker
import java.time.LocalTime
@Composable
fun HearingSchedulePicker() {
var selectedTime by remember { mutableStateOf<LocalTime?>(null) }
Ux4gTimePicker(
selectedTime = selectedTime,
onTimeSelected = { time -> selectedTime = time },
label = "Grievance Hearing Time",
isRequired = true,
placeholder = "Select hearing time"
)
}Parameters
Ux4gTimePicker Props
| Prop | Type | Description | Default |
|---|---|---|---|
selectedTime | Ux4gTimeOfDay? / LocalTime? | Currently selected time value displayed in the input box. | null |
onTimeSelected * | (Ux4gTimeOfDay) -> Unit / (LocalTime) -> Unit | Callback triggered when the citizen confirms a time in the dialog modal. | — |
modifier | Modifier | Compose layout modifier applied to the outer container. | Modifier |
placeholder | String | Placeholder text shown when no time is selected. | "Select time" |
enabled | Boolean | Controls interactive touch state and disabled opacity. | true |
minuteInterval | Int | Step increment for the minute scroll wheel (1, 5, 10, 15, 30). | 1 |
label | String? | Header title displayed above the time input box. | null |
description | String? | Supplementary helper or validation message displayed below input. | null |
isRequired | Boolean | When true, appends a red asterisk (*) to the label. | false |
colors | Ux4gTimePickerColors | Custom color palette configuration for input and dialog wheel elements. | Ux4gTimePickerDefaults.colors() |
Ux4gTimeOfDay Data Class Reference
| Property / Method | Type / Signature | Description |
|---|---|---|
hour * | Int | 24-hour format hour (0..23). |
minute * | Int | Minute of the hour (0..59). |
hourOfPeriod | Int | 12-hour period hour (1..12). |
isAm | Boolean | Returns true if before noon (hour < 12), false for PM. |
format() | (placeholder: String) -> String | Returns formatted string (e.g., "05:02 PM"). |
toLocalTime() | () -> LocalTime | Converts to standard java.time.LocalTime. |
now() | () -> Ux4gTimeOfDay | Static constructor capturing system local current time. |
fromLocalTime() | (LocalTime) -> Ux4gTimeOfDay | Static helper converting LocalTime to Ux4gTimeOfDay. |
of() | (hour: Int, minute: Int, isAm: Boolean) -> Ux4gTimeOfDay | Static helper constructing instance from 12-hour values. |