Date Picker

The date picker is an input field that allows you to select dates through textual input or interaction with a calendar options overlay.

TypeResource
DesignFigma
MobileWeb Storybook
CodeGitlab

DatePicker Preview

Usage

import id.co.biofarma.binduiandroid.components.datepicker.*
    var selectedDate by remember(config.initialDate) {
        mutableStateOf(config.initialDate)
      }
 
      DateInput(
          label = "Configured Date Picker",
          value = selectedDate,
          variant = TextInputVariant.OUTLINE,
          dateFormat = "dd-MM-yyyy",
          placeholder = "Select date",
          disabled = false,
          isRequired = true,
          iconPosition = IconPosition.END,
          onDateSelected = { date -> selectedDate = date },
          datePickerParams = DatePickerParams(
              confirmButtonText = "OK",
              dismissButtonText = "Cancel",
              selectableDates = when (config.dateFilter) {
                  "past" -> PresentPastSelectableDates()
                  "future" -> FutureSelectableDates()
                  "custom" -> ConfigurableSelectableDates(
                      minDate = LocalDate.now().minusDays(7),
                      maxDate = LocalDate.now().plusDays(7)
                  )
                  else -> DatePickerDefaults.AllDates
              },
          shape = config.radius?.let { RoundedCornerShape(it) } ?: RectangleShape
          )
      )

Examples

selectableDates

Use selectableDates to determine allowed date range.

DatePicker selectableDates


DateRangeInput

Use DateRangeInput to select date range.

DateRangeInput


dateFormat

Use dateFormat to determine date formatting.

DatePicker dateFormat


Props

PropsRequiredDefaultTypeDescription
idfalse-StringUnique identifier for date picker
variantfalseTextInputVariant.OUTLINETextInputVariantSet variant of input
labelfalse-StringSet input label of date picker
valuefalse-LocalDate?Used to bind value of selected date
placeholderfalse-StringSet placeholer of input
helperTextfalse-StringSet helper text of input
errorTextfalse-StringBind when date input error
disabledfalsefalseBooleanToggle for enabling input
isErrorfalsefalseBooleantrue when input is error
isRequiredfalsefalseBooleanDetermine if input is required
prefixAddsOnfalse-StringAllows the addition of a prefix (like a currency symbol or an icon) at the beginning of the input field.
suffixAddsOnfalsenull@Composable (() -> Unit)?Allows the addition of a suffix (like a unit or a button) at the end of the input field.
dateFormatfalsedd/MM/yyyyStringDeterimine date formatting of input value
sizefalseComponentSize.MDComponentSizeSet size of input component
radiusfalseComponentRadius.MDComponentRadiusSet corner of input component
radiusfalseComponentRadius.MDComponentRadiusSet corner of input component
modefalseThemeMode.LIGHTThemeModeSet theme to dark or light
stylefalseModifierModifierChange style of component using modifier
datePickerParamsfalseDatePickerParams()DatePickerParamsSet date picker params
iconfalse{ DefaultCalendarIcon(disabled = disabled) }@Composable (() -> Unit)?Set icon of date picker
iconPositionfalseIconPosition.ENDIconPositionSet icon position of date picker
onDateSelectedtrue-(LocalDate?) -> UnitCallback when user selected date
BIND © Biofarma Innovate Next-level Design .