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:
- Single Date Picker (
Ux4gDatePickerMode.Single): Form input field with calendar trigger icon, custom label, required asterisk, and status validation messages. - Date Range Picker (
Ux4gDatePickerMode.Range): Dual-box start and end date selector for booking periods, financial years, and service timelines. - 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

2. Date Range Picker (Ux4gDatePickerMode.Range)
Ux4gDatePicker - Range Date SelectionJetpack Compose

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:

Modal dialog view with month/year navigation, weekday column headers, date range highlights, and Confirm / Cancel action buttons.
Kotlin Usage
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
| Prop | Type | Description | Default |
|---|---|---|---|
modifier | Modifier | Compose layout modifier applied to outer container. | Modifier |
mode | Ux4gDatePickerMode | Picker mode: Ux4gDatePickerMode.Single or Ux4gDatePickerMode.Range. | Ux4gDatePickerMode.Single |
selectedDate | LocalDate? | Currently selected date in Single mode. | null |
selectedDateRange | Ux4gDateRange? | Currently selected date range (start and end) in Range mode. | null |
minDate | LocalDate? | Earliest selectable date constraint. Earlier dates are disabled. | null |
maxDate | LocalDate? | 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 |
placeholder | String | Hint text displayed inside input box when no date is selected. | "Select date" |
enabled | Boolean | Whether the date picker input is interactive. | true |
label | String? | Header title displayed above the date input field. | null |
description | String? | Supplementary helper or validation message displayed below input. | null |
isRequired | Boolean | When true, appends red asterisk (*) to the label. | false |
status | Ux4gInputFieldStatus | Status validation style: Default, Error, Warning, Success. | Ux4gInputFieldStatus.Default |
Ux4gDateRange Data Class
| Prop | Type | Description |
|---|---|---|
start * | LocalDate | Beginning date of the selected date range. |
end * | LocalDate | Ending date of the selected date range. |
Ux4gDatePickerMode Enum
| Value | Description |
|---|---|
Single | Single date input trigger box and single day cell selection. |
Range | Dual-box start and end input layout with highlighted date range interval. |