Time picker

Lets people choose a time on a dial or by typing it.

When to use

Use the dial picker for quick selection with touch or pointer, and TimeInput when the time is known and typing is faster. TimePickerDialog hosts either one, with a toggle to switch.

Honor the user's 12 or 24 hour preference through the is24Hour parameter.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

In a dialog

var open by rememberSaveable { mutableStateOf(false) }
val state = rememberTimePickerState(initialHour = 9, initialMinute = 30)

Button(onClick = { open = true }) { Text("Pick a time") }

if (open) {
    TimePickerDialog(
        onDismissRequest = { open = false },
        title = { Text("Select time") },
        confirmButton = { TextButton(onClick = { open = false }) { Text("OK") } },
        dismissButton = { TextButton(onClick = { open = false }) { Text("Cancel") } },
    ) {
        TimePicker(state = state)
    }
}

Parameters

NameTypeDefaultDescription
stateTimePickerStaterememberTimePickerState(initialHour, initialMinute, is24Hour).
layoutTypeTimePickerLayoutTypeTimePickerDefaults.layoutType()Vertical for portrait, Horizontal for landscape.
colorsTimePickerColorsTimePickerDefaults.colors()Dial, selector and period selector colors.

Guidelines

Do:

Don't:

Accessibility

Related components