Components
DatePicker
Select a date or time using the browser’s native input.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { useState } from 'react';
import { DatePicker } from '@swiftuijs/ui';
import { VStack } from '@swiftuijs/ui';
import { Text } from '@swiftuijs/ui';
const ControlledDateDemo = () => {
const [date, setDate] = useState('2026-04-10');
return (<VStack spacing={16}>
<Text>Selected: {date}</Text>
<DatePicker aria-label="Controlled date" selection={date} onSelectionChange={setDate} mode="date"/>
</VStack>);
};
export default function Example() {
return (<ControlledDateDemo />);
}Usage and limitations
- Controlled:
selectionandonSelectionChange; uncontrolled:defaultSelection. React aliases arevalue,defaultValue, andonValueChange.onChangereceives the native event. dateusesYYYY-MM-DD,timeusesHH:MM, anddateAndTimeusesYYYY-MM-DDTHH:MM. The browser localizes display, not the stored string.displayedComponents={['date', 'hourAndMinute']}selectsdateAndTime; a single component selects its respective mode.min/maxuse the same native string format.minuteIntervalsets native step for time/date-time modes;disabledis a native input prop.- Provide a visible label or
aria-label; test native picker behavior on your target mobile browsers.
More examples
Uncontrolled Usage
Date and Time
SwiftUI-Style Components
Minute Interval
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
selection | string | No | SwiftUI-style alias for the current native input value. |
value | string | No | The current native input value. |
defaultSelection | string | No | SwiftUI-style alias for the initial uncontrolled value. |
defaultValue | string | No | The initial native input value when uncontrolled. |
onChange | ChangeEventHandler<HTMLInputElement> | No | Native input change handler. |
onSelectionChange | (value: string) => void | No | SwiftUI-style value-first change handler. |
onValueChange | (value: string) => void | No | Value-first change handler for SwiftUI-style ergonomics. |
min | string | No | The minimum selectable value, expressed in the same native input format as `value`. |
max | string | No | The maximum selectable value, expressed in the same native input format as `value`. |
minimumDate | string | No | Backward-compatible minimum alias for SwiftUI-style callers. |
maximumDate | string | No | Backward-compatible maximum alias for SwiftUI-style callers. |
mode | DatePickerMode | No | The display mode of the date picker. Default: 'date' |
displayedComponents | DatePickerDisplayedComponent[] | No | SwiftUI-style displayed components. When provided, these values determine the native input type. |
minuteInterval | number | No | SwiftUI-style minute granularity for time-based pickers. |
disabled | boolean | No | Whether the date picker is disabled. Default: false |
Inherits additional props from Omit<
IBaseElementComponent<'input'>,
'type' | 'value' | 'defaultValue' | 'onChange' | 'children' | 'min' | 'max'
>.