androidx.compose.material3

DatePicker

Composable function

A date picker shows a calendar to pick a date. The user can also switch to typing the date.

The picker keeps its choice in a state. Create it with rememberDatePickerState(), and read state.selectedDateMillis. Dates are milliseconds since 1 January 1970, in UTC. Convert them with kotlinx-datetime or java.time.

A date picker with a selected date
A date picker with a selected date
// Dates are milliseconds since 1970 (UTC). This is 12 May 2026.
val state = rememberDatePickerState(initialSelectedDateMillis = 1_778_544_000_000L)
DatePicker(state = state, modifier = Modifier.width(360.dp))
// Read the choice with state.selectedDateMillis

DateRangePicker picks a start and an end date. Read selectedStartDateMillis and selectedEndDateMillis from its state.

Pick a start and end date
Pick a start and end date
val state = rememberDateRangePickerState(
    initialSelectedStartDateMillis = 1_778_544_000_000L,
    initialSelectedEndDateMillis = 1_778_803_200_000L,
)
DateRangePicker(state = state, modifier = Modifier.size(360.dp, 520.dp))

To show the picker in a dialog, put it inside a DatePickerDialog, with OK and Cancel buttons.

Parameters

@Composable
fun DatePicker(
    state: DatePickerState,
    modifier: Modifier = Modifier,
    dateFormatter: DatePickerFormatter = remember { DatePickerDefaults.dateFormatter() },
    colors: DatePickerColors = DatePickerDefaults.colors(),
    title: (@Composable () -> Unit)? = { DatePickerDefaults.DatePickerTitle(displayMode = state.displayMode, modifier = Modifier.padding(DatePickerTitlePadding), contentColor = colors.titleContentColor) },
    headline: (@Composable () -> Unit)? = { DatePickerDefaults.DatePickerHeadline(selectedDateMillis = state.selectedDateMillis, displayMode = state.displayMode, dateFormatter = dateFormatter, modifier = Modifier.padding(DatePickerHeadlinePadding), contentColor = colors.headlineContentColor) },
    showModeToggle: Boolean = true,
    focusRequester: FocusRequester? = remember { FocusRequester() },
)

state: DatePickerStateRequired

Holds the selected date, the shown month, the year range and which dates can be picked. Create it with rememberDatePickerState(initialSelectedDateMillis = ...) or rememberDateRangePickerState(...). To block some dates, pass selectableDates to it.

modifier: ModifierOptional

Default: Modifier

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

dateFormatter: DatePickerFormatterOptional

Default: remember { DatePickerDefaults.dateFormatter() }

How dates and months are written in the headline and year list.

colors: DatePickerColorsOptional

Default: DatePickerDefaults.colors()

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

title: (@Composable () -> Unit)?Optional

Default: { DatePickerDefaults.DatePickerTitle(displayMode = state.displayMode, modifier = Modifier.padding(DatePickerTitlePadding), contentColor = colors.titleContentColor) }

The small text at the top, like "Select date". Pass null to hide it.

headline: (@Composable () -> Unit)?Optional

Default: { DatePickerDefaults.DatePickerHeadline(selectedDateMillis = state.selectedDateMillis, displayMode = state.displayMode, dateFormatter = dateFormatter, modifier = Modifier.padding(DatePickerHeadlinePadding), contentColor = colors.headlineContentColor) }

The large text showing the chosen date. Pass null to hide it.

showModeToggle: BooleanOptional

Default: true

Set to false to hide the pencil button that switches to typing the date.

focusRequester: FocusRequester?OptionalSince 1.9

Default: remember { FocusRequester() }

Moves keyboard focus to the picker when it opens.

Types and parts

See also