# TimePickerDialog

> TimePickerDialog from Material 3 Compose (`androidx.compose.material3:material3`) for Jetpack Compose, with a code sample.

- Library: [Material 3 Compose](https://composables.com/material-components/material-3-compose.md)
- Category: [Dialogs](https://composables.com/material-components/dialogs.md)
- Category: [Pickers](https://composables.com/material-components/pickers.md)
- Category: [Time](https://composables.com/material-components/time.md)
- API reference and more examples: [TimePickerDialog](https://composables.com/jetpack-compose/androidx.compose.material3/material3/components/TimePickerDialog/api.md)

## Code

```kotlin
@Composable
fun TimePickerDialogSample() {
    var showDialog by remember { mutableStateOf(true) }
    val timePickerState = rememberTimePickerState(initialHour = 10, initialMinute = 30)

    Button(onClick = { showDialog = true }) {
        Text("Select time")
    }

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