object DatePickerDefaults
Contains default values used by the DatePicker.
Properties
val YearRange: IntRange
The range of years for the date picker dialogs.
val TonalElevation: Dp
The default tonal elevation used for DatePickerDialog.
val shape: Shape
The default shape for date picker dialogs.
val AllDates: SelectableDates
A default SelectableDates that allows all dates to be selected.
const val YearMonthSkeleton: String
A date format skeleton used to format the date picker's year selection menu button (e.g. "March 2021")
const val YearAbbrMonthDaySkeleton: String
A date format skeleton used to format a selected date (e.g. "Mar 27, 2021")
const val YearMonthWeekdayDaySkeleton: String
A date format skeleton used to format a selected date to be used as content description for screen readers (e.g. "Saturday, March 27, 2021")
Functions
@Composable fun colors() = MaterialTheme.colorScheme.defaultDatePickerColors
Creates a DatePickerColors that will potentially animate between the provided colors according to the Material specification.
colors
@Composable
fun colors(
containerColor: Color = Color.Unspecified,
titleContentColor: Color = Color.Unspecified,
headlineContentColor: Color = Color.Unspecified,
weekdayContentColor: Color = Color.Unspecified,
subheadContentColor: Color = Color.Unspecified,
navigationContentColor: Color = Color.Unspecified,
yearContentColor: Color = Color.Unspecified,
disabledYearContentColor: Color = Color.Unspecified,
currentYearContentColor: Color = Color.Unspecified,
selectedYearContentColor: Color = Color.Unspecified,
disabledSelectedYearContentColor: Color = Color.Unspecified,
selectedYearContainerColor: Color = Color.Unspecified,
disabledSelectedYearContainerColor: Color = Color.Unspecified,
dayContentColor: Color = Color.Unspecified,
disabledDayContentColor: Color = Color.Unspecified,
selectedDayContentColor: Color = Color.Unspecified,
disabledSelectedDayContentColor: Color = Color.Unspecified,
selectedDayContainerColor: Color = Color.Unspecified,
disabledSelectedDayContainerColor: Color = Color.Unspecified,
todayContentColor: Color = Color.Unspecified,
todayDateBorderColor: Color = Color.Unspecified,
dayInSelectionRangeContentColor: Color = Color.Unspecified,
dayInSelectionRangeContainerColor: Color = Color.Unspecified,
dividerColor: Color = Color.Unspecified,
dateTextFieldColors: TextFieldColors? = null,
): DatePickerColors
Creates a DatePickerColors that will potentially animate between the provided colors according to the Material specification.
Parameters
| containerColor | the color used for the date picker's background |
| titleContentColor | the color used for the date picker's title |
| headlineContentColor | the color used for the date picker's headline |
| weekdayContentColor | the color used for the weekday letters |
| subheadContentColor | the color used for the month and year subhead labels that appear when months are displayed at a DateRangePicker. |
| navigationContentColor | the content color used for the year selection menu button and the months arrow navigation when displayed at a DatePicker. |
| yearContentColor | the color used for a year item content |
| disabledYearContentColor | the color used for a disabled year item content |
| currentYearContentColor | the color used for the current year content when selecting a year |
| selectedYearContentColor | the color used for a selected year item content |
| disabledSelectedYearContentColor | the color used for a disabled selected year item content |
| selectedYearContainerColor | the color used for a selected year item container |
| disabledSelectedYearContainerColor | the color used for a disabled selected year item container |
| dayContentColor | the color used for days content |
| disabledDayContentColor | the color used for disabled days content |
| selectedDayContentColor | the color used for selected days content |
| disabledSelectedDayContentColor | the color used for disabled selected days content |
| selectedDayContainerColor | the color used for a selected day container |
| disabledSelectedDayContainerColor | the color used for a disabled selected day container |
| todayContentColor | the color used for the day that marks the current date |
| todayDateBorderColor | the color used for the border of the day that marks the current date |
| dayInSelectionRangeContentColor | the content color used for days that are within a date range selection |
| dayInSelectionRangeContainerColor | the container color used for days that are within a date range selection |
| dividerColor | the color used for the dividers used at the date pickers |
| dateTextFieldColors | the TextFieldColors defaults for the date text field when in DisplayMode.Input. See OutlinedTextFieldDefaults.colors. |
dateFormatter
fun dateFormatter(
yearSelectionSkeleton: String = YearMonthSkeleton,
selectedDateSkeleton: String = YearAbbrMonthDaySkeleton,
selectedDateDescriptionSkeleton: String = YearMonthWeekdayDaySkeleton,
): DatePickerFormatter
Returns a DatePickerFormatter.
The date formatter will apply the best possible localized form of the given skeleton and Locale. A skeleton is similar to, and uses the same format characters as, a Unicode UTS #35 pattern.
One difference is that order is irrelevant. For example, "MMMMd" will return "MMMM d" in the en_US locale, but "d. MMMM" in the de_CH locale.
Parameters
| yearSelectionSkeleton | a date format skeleton used to format the date picker's year selection menu button (e.g. "March 2021"). |
| selectedDateSkeleton | a date format skeleton used to format a selected date (e.g. "Mar 27, 2021") |
| selectedDateDescriptionSkeleton | a date format skeleton used to format a selected date to be used as content description for screen readers (e.g. "Saturday, March 27, 2021") |
DatePickerTitle
@Composable
fun DatePickerTitle(
displayMode: DisplayMode,
modifier: Modifier = Modifier,
contentColor: Color = colors().titleContentColor,
)
A default date picker title composable.
Parameters
| displayMode | the current DisplayMode |
| modifier | a Modifier to be applied for the title |
| contentColor | the content color of this title |
DatePickerHeadline
@Composable
fun DatePickerHeadline(
@Suppress("AutoBoxing") selectedDateMillis: Long?,
displayMode: DisplayMode,
dateFormatter: DatePickerFormatter,
modifier: Modifier = Modifier,
contentColor: Color = colors().headlineContentColor,
)
A default date picker headline composable that displays a default headline text when there is no date selection, and an actual date string when there is.
Parameters
| selectedDateMillis | a timestamp that represents the selected date start of the day in UTC milliseconds from the epoch |
| displayMode | the current DisplayMode |
| dateFormatter | a DatePickerFormatter |
| modifier | a Modifier to be applied for the headline |
| contentColor | the content color of this headline |