{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DatePickerDefaults

@ExperimentalMaterial3Api
public static class DatePickerDefaults


Contains default values used by the DatePicker.

Summary

Constants

static final @NonNull String

A date format skeleton used to format a selected date (e.g. "Mar 27, 2021")

static final @NonNull String

A date format skeleton used to format the date picker's year selection menu button (e.g. "March 2021")

static final @NonNull 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")

Public fields

static @NonNull DatePickerDefaults

Public methods

final void
@Composable
DatePickerHeadline(
    Long selectedDateMillis,
    @NonNull DisplayMode displayMode,
    @NonNull DatePickerFormatter dateFormatter,
    @NonNull Modifier modifier
)

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.

final void
@Composable
DatePickerTitle(
    @NonNull DisplayMode displayMode,
    @NonNull Modifier modifier
)

A default date picker title composable.

final @NonNull DatePickerColors

Creates a DatePickerColors that will potentially animate between the provided colors according to the Material specification.

final @NonNull DatePickerColors
@Composable
colors(
    @NonNull Color containerColor,
    @NonNull Color titleContentColor,
    @NonNull Color headlineContentColor,
    @NonNull Color weekdayContentColor,
    @NonNull Color subheadContentColor,
    @NonNull Color navigationContentColor,
    @NonNull Color yearContentColor,
    @NonNull Color disabledYearContentColor,
    @NonNull Color currentYearContentColor,
    @NonNull Color selectedYearContentColor,
    @NonNull Color disabledSelectedYearContentColor,
    @NonNull Color selectedYearContainerColor,
    @NonNull Color disabledSelectedYearContainerColor,
    @NonNull Color dayContentColor,
    @NonNull Color disabledDayContentColor,
    @NonNull Color selectedDayContentColor,
    @NonNull Color disabledSelectedDayContentColor,
    @NonNull Color selectedDayContainerColor,
    @NonNull Color disabledSelectedDayContainerColor,
    @NonNull Color todayContentColor,
    @NonNull Color todayDateBorderColor,
    @NonNull Color dayInSelectionRangeContentColor,
    @NonNull Color dayInSelectionRangeContainerColor,
    @NonNull Color dividerColor,
    TextFieldColors dateTextFieldColors
)

Creates a DatePickerColors that will potentially animate between the provided colors according to the Material specification.

final @NonNull DatePickerFormatter
dateFormatter(
    @NonNull String yearSelectionSkeleton,
    @NonNull String selectedDateSkeleton,
    @NonNull String selectedDateDescriptionSkeleton
)

Returns a DatePickerFormatter.

final @NonNull SelectableDates

A default SelectableDates that allows all dates to be selected.

final @NonNull Shape

The default shape for date picker dialogs.

final @NonNull Dp

The default tonal elevation used for DatePickerDialog.

final @NonNull IntRange

The range of years for the date picker dialogs.

Constants

YearAbbrMonthDaySkeleton

public static final @NonNull String YearAbbrMonthDaySkeleton

A date format skeleton used to format a selected date (e.g. "Mar 27, 2021")

YearMonthSkeleton

public static final @NonNull String YearMonthSkeleton

A date format skeleton used to format the date picker's year selection menu button (e.g. "March 2021")

YearMonthWeekdayDaySkeleton

public static final @NonNull String YearMonthWeekdayDaySkeleton

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")

Public fields

INSTANCE

public static @NonNull DatePickerDefaults INSTANCE

Public methods

DatePickerHeadline

@Composable
public final void DatePickerHeadline(
    Long selectedDateMillis,
    @NonNull DisplayMode displayMode,
    @NonNull DatePickerFormatter dateFormatter,
    @NonNull Modifier modifier
)

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
Long selectedDateMillis

a timestamp that represents the selected date start of the day in UTC milliseconds from the epoch

@NonNull DisplayMode displayMode

the current DisplayMode

@NonNull DatePickerFormatter dateFormatter

a DatePickerFormatter

@NonNull Modifier modifier

a Modifier to be applied for the headline

DatePickerTitle

@Composable
public final void DatePickerTitle(
    @NonNull DisplayMode displayMode,
    @NonNull Modifier modifier
)

A default date picker title composable.

Parameters
@NonNull DisplayMode displayMode

the current DisplayMode

@NonNull Modifier modifier

a Modifier to be applied for the title

colors

@Composable
public final @NonNull DatePickerColors colors()

Creates a DatePickerColors that will potentially animate between the provided colors according to the Material specification.

colors

@Composable
public final @NonNull DatePickerColors colors(
    @NonNull Color containerColor,
    @NonNull Color titleContentColor,
    @NonNull Color headlineContentColor,
    @NonNull Color weekdayContentColor,
    @NonNull Color subheadContentColor,
    @NonNull Color navigationContentColor,
    @NonNull Color yearContentColor,
    @NonNull Color disabledYearContentColor,
    @NonNull Color currentYearContentColor,
    @NonNull Color selectedYearContentColor,
    @NonNull Color disabledSelectedYearContentColor,
    @NonNull Color selectedYearContainerColor,
    @NonNull Color disabledSelectedYearContainerColor,
    @NonNull Color dayContentColor,
    @NonNull Color disabledDayContentColor,
    @NonNull Color selectedDayContentColor,
    @NonNull Color disabledSelectedDayContentColor,
    @NonNull Color selectedDayContainerColor,
    @NonNull Color disabledSelectedDayContainerColor,
    @NonNull Color todayContentColor,
    @NonNull Color todayDateBorderColor,
    @NonNull Color dayInSelectionRangeContentColor,
    @NonNull Color dayInSelectionRangeContainerColor,
    @NonNull Color dividerColor,
    TextFieldColors dateTextFieldColors
)

Creates a DatePickerColors that will potentially animate between the provided colors according to the Material specification.

Parameters
@NonNull Color containerColor

the color used for the date picker's background

@NonNull Color titleContentColor

the color used for the date picker's title

@NonNull Color headlineContentColor

the color used for the date picker's headline

@NonNull Color weekdayContentColor

the color used for the weekday letters

@NonNull Color subheadContentColor

the color used for the month and year subhead labels that appear when months are displayed at a DateRangePicker.

@NonNull Color navigationContentColor

the content color used for the year selection menu button and the months arrow navigation when displayed at a DatePicker.

@NonNull Color yearContentColor

the color used for a year item content

@NonNull Color disabledYearContentColor

the color used for a disabled year item content

@NonNull Color currentYearContentColor

the color used for the current year content when selecting a year

@NonNull Color selectedYearContentColor

the color used for a selected year item content

@NonNull Color disabledSelectedYearContentColor

the color used for a disabled selected year item content

@NonNull Color selectedYearContainerColor

the color used for a selected year item container

@NonNull Color disabledSelectedYearContainerColor

the color used for a disabled selected year item container

@NonNull Color dayContentColor

the color used for days content

@NonNull Color disabledDayContentColor

the color used for disabled days content

@NonNull Color selectedDayContentColor

the color used for selected days content

@NonNull Color disabledSelectedDayContentColor

the color used for disabled selected days content

@NonNull Color selectedDayContainerColor

the color used for a selected day container

@NonNull Color disabledSelectedDayContainerColor

the color used for a disabled selected day container

@NonNull Color todayContentColor

the color used for the day that marks the current date

@NonNull Color todayDateBorderColor

the color used for the border of the day that marks the current date

@NonNull Color dayInSelectionRangeContentColor

the content color used for days that are within a date range selection

@NonNull Color dayInSelectionRangeContainerColor

the container color used for days that are within a date range selection

@NonNull Color dividerColor

the color used for the dividers used at the date pickers

TextFieldColors dateTextFieldColors

the TextFieldColors defaults for the date text field when in DisplayMode.Input. See OutlinedTextFieldDefaults.colors.

dateFormatter

public final @NonNull DatePickerFormatter dateFormatter(
    @NonNull String yearSelectionSkeleton,
    @NonNull String selectedDateSkeleton,
    @NonNull String selectedDateDescriptionSkeleton
)

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
@NonNull String yearSelectionSkeleton

a date format skeleton used to format the date picker's year selection menu button (e.g. "March 2021").

@NonNull String selectedDateSkeleton

a date format skeleton used to format a selected date (e.g. "Mar 27, 2021")

@NonNull String 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")

getAllDates

public final @NonNull SelectableDates getAllDates()

A default SelectableDates that allows all dates to be selected.

getShape

@Composable
public final @NonNull Shape getShape()

The default shape for date picker dialogs.

getTonalElevation

public final @NonNull Dp getTonalElevation()

The default tonal elevation used for DatePickerDialog.

getYearRange

public final @NonNull IntRange getYearRange()

The range of years for the date picker dialogs.