androidx.compose.material3

TimePicker

Composable function

A time picker picks an hour and a minute. TimePicker shows a clock dial. TimeInput shows two text fields, which is better with a keyboard.

The picker keeps its choice in a state. Create it with rememberTimePickerState(), and read state.hour and state.minute.

A clock dial
A clock dial
val state = rememberTimePickerState(initialHour = 9, initialMinute = 30, is24Hour = false)
TimePicker(state = state, layoutType = TimePickerLayoutType.Vertical)
// Read the choice with state.hour and state.minute
Type the time instead
Type the time instead
val state = rememberTimePickerState(initialHour = 18, initialMinute = 45, is24Hour = true)
TimeInput(state = state)

To show the picker in a dialog, put it inside a TimePickerDialog.

Basic

Uses the default shapes.

@Composable
fun TimePicker(
    state: TimePickerState,
    modifier: Modifier = Modifier,
    colors: TimePickerColors = TimePickerDefaults.colors(),
    layoutType: TimePickerLayoutType = TimePickerDefaults.layoutType(),
)

state: TimePickerStateRequired

Holds the hour, the minute, and whether the clock uses 24 hours. Create it with rememberTimePickerState(initialHour = 9, initialMinute = 30). is24Hour follows the system setting by default.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. See the Modifier guide.

colors: TimePickerColorsOptional

Default: TimePickerDefaults.colors()

Sets all colors of the picker. Make one with TimePickerDefaults.colors.

layoutType: TimePickerLayoutTypeOptional

Default: TimePickerDefaults.layoutType()

Puts the dial below the time (Vertical) or beside it (Horizontal). Default: depends on the screen shape.

ExpressiveSince 1.12

Takes shapes for the time boxes and AM/PM buttons.

@Composable
fun TimePicker(
    state: TimePickerState,
    shapes: TimePickerShapes,
    modifier: Modifier = Modifier,
    colors: TimePickerColors = TimePickerDefaults.richColors(),
    layoutType: TimePickerLayoutType = TimePickerDefaults.layoutType(),
)

shapes: TimePickerShapesRequired

Sets the shapes of the time boxes and the AM/PM buttons.

Same as above: state, modifier, colors, layoutType.

Types and parts

See also