UX4G Logo
Components

Date Picker

Date selection input and calendar dialog supporting Single date mode, Range selection, month/year grid switchers, status validations, and date constraints

The UX4G Date Picker suite provides accessible date selection components following government form guidelines with integrated calendar dialog modals, month/year grid quick-pickers, and dual-field date range selectors:

  1. Single Date Picker (Ux4gDatePickerMode.Single): Form input field with calendar trigger icon, custom label, required asterisk, and status validation messages.
  2. Date Range Picker (Ux4gDatePickerMode.Range): Dual-box start and end date selector for booking periods, financial years, and service timelines.
  3. Calendar Dialog Modal: Full-featured calendar modal automatically invoked when a citizen taps the date picker input.

Import from com.ux4g.designsystemv1.components.Ux4gDatePicker.


Interactive Previews

1. Single Date Picker (Ux4gDatePickerMode.Single)

Ux4gDatePicker - Single Date SelectionJetpack Compose
UX4G Single Date Picker Preview

2. Date Range Picker (Ux4gDatePickerMode.Range)

Ux4gDatePicker - Range Date SelectionJetpack Compose
UX4G Date Range Picker Preview

3. Calendar Dialog Modal (Auto-Opened on Click)

When a citizen clicks on either the Single or Range date picker input field, the interactive calendar dialog modal opens automatically to allow day, month, and year selection:

UX4G Date Picker Dialog Modal

Modal dialog view with month/year navigation, weekday column headers, date range highlights, and Confirm / Cancel action buttons.


Kotlin Usage

Date Picker Showcase Example
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.Ux4gDatePicker
import com.ux4g.designsystemv1.components.Ux4gDatePickerMode
import com.ux4g.designsystemv1.components.Ux4gDateRange
import com.ux4g.designsystemv1.components.inputfield.Ux4gInputFieldStatus
import com.ux4g.designsystemv1.foundation.defaultTypography
import java.time.LocalDate

@Composable
fun DatePickerShowcaseScreen() {
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(20.dp)
    ) {
        // 1. Single Date Picker with Required Flag
        Text("Single Date Picker", style = defaultTypography.hS_strong)
        var birthDate by remember { mutableStateOf<LocalDate?>(LocalDate.now()) }
        Ux4gDatePicker(
            label = "Date of Birth",
            isRequired = true,
            selectedDate = birthDate,
            onDateSelected = { birthDate = it },
            description = "Select your birth date for verification"
        )

        // 2. Date Range Picker
        Text("Date Range Picker", style = defaultTypography.hS_strong)
        var bookingRange by remember {
            mutableStateOf<Ux4gDateRange?>(
                Ux4gDateRange(LocalDate.now(), LocalDate.now().plusDays(5))
            )
        }
        Ux4gDatePicker(
            mode = Ux4gDatePickerMode.Range,
            label = "Booking Period",
            selectedDateRange = bookingRange,
            onDateRangeSelected = { bookingRange = it },
            description = "Select start and end dates"
        )

        // 3. Validation States
        Text("Validation States", style = defaultTypography.hS_strong)
        Ux4gDatePicker(
            label = "Error State",
            status = Ux4gInputFieldStatus.Error,
            description = "Please select a valid future date"
        )

        Ux4gDatePicker(
            label = "Success State",
            status = Ux4gInputFieldStatus.Success,
            selectedDate = LocalDate.now(),
            description = "Appointment slot available"
        )

        Ux4gDatePicker(
            label = "Disabled State",
            enabled = false,
            description = "This field is locked during submission"
        )
    }
}

Parameters

Ux4gDatePicker Props

PropTypeDescriptionDefault
modifierModifierCompose layout modifier applied to outer container.Modifier
modeUx4gDatePickerModePicker mode: Ux4gDatePickerMode.Single or Ux4gDatePickerMode.Range.Ux4gDatePickerMode.Single
selectedDateLocalDate?Currently selected date in Single mode.null
selectedDateRangeUx4gDateRange?Currently selected date range (start and end) in Range mode.null
minDateLocalDate?Earliest selectable date constraint. Earlier dates are disabled.null
maxDateLocalDate?Latest selectable date constraint (e.g. LocalDate.now()).null
onDateSelected((LocalDate) -> Unit)?Callback invoked when a date is confirmed in Single mode.null
onDateRangeSelected((Ux4gDateRange) -> Unit)?Callback invoked when a date range is confirmed in Range mode.null
placeholderStringHint text displayed inside input box when no date is selected."Select date"
enabledBooleanWhether the date picker input is interactive.true
labelString?Header title displayed above the date input field.null
descriptionString?Supplementary helper or validation message displayed below input.null
isRequiredBooleanWhen true, appends red asterisk (*) to the label.false
statusUx4gInputFieldStatusStatus validation style: Default, Error, Warning, Success.Ux4gInputFieldStatus.Default

Ux4gDateRange Data Class

PropTypeDescription
start *LocalDateBeginning date of the selected date range.
end *LocalDateEnding date of the selected date range.

Ux4gDatePickerMode Enum

ValueDescription
SingleSingle date input trigger box and single day cell selection.
RangeDual-box start and end input layout with highlighted date range interval.

On this page