Date range picker

Lets people pick a start and an end date on a scrolling calendar.

When to use

Use it for stays, trips and reports. The first tap sets the start, the second sets the end. Offer the text input mode for people who prefer to type.

Give the picker a fixed height or a weight, because the calendar scrolls inside it.

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 = rememberDateRangePickerState()

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

if (open) {
    DatePickerDialog(
        onDismissRequest = { open = false },
        confirmButton = { TextButton(onClick = { open = false }) { Text("Save") } },
        dismissButton = { TextButton(onClick = { open = false }) { Text("Cancel") } },
    ) {
        DateRangePicker(state = state, modifier = Modifier.height(500.dp))
    }
}

Parameters

NameTypeDefaultDescription
stateDateRangePickerStateExposes selectedStartDateMillis and selectedEndDateMillis.
selectableDatesSelectableDatesAllDatesRestrict dates.
showModeToggleBooleantrueSwitch between calendar and input.

Guidelines

Do:

Don't:

Accessibility

Related components