Date picker
Shared date API for the OS native picker or a token-aware calendar sheet.
npx @swipeui/cli add date-pickerWhen to use it
- Date fields in forms, such as birthday, start date or due date.
- Using the system date picker people already know.
- A custom calendar sheet that matches your theme, with Cancel and Apply.
- Fields that need min and max dates or blocked days.
When not to use it
- Picking a range. Use Date range picker.
- Time only. Use Time picker.
- A calendar that's always visible on screen. Use Calendar.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add date-picker- Adds
components/swipeui/ui/use-date-picker.ts,components/swipeui/ui/picker-support.ts,components/swipeui/ui/use-picker-warning.ts,components/swipeui/ui/date-picker.tsxand 19 shared helpers. - Installs react-native-svg, @expo/ui, uniwind, clsx, tailwind-merge, react-native-reanimated, react-native-worklets, class-variance-authority, expo-haptics, react-native-gesture-handler, react-native-safe-area-context, @gorhom/bottom-sheet, expo-blur. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { DatePicker } from '@/components/swipeui/ui/date-picker';
<DatePicker label="Appointment" />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
DatePickerProps
| Prop | Type | Default | Description |
|---|---|---|---|
minDate? | | — | The earliest day that can be chosen. |
maxDate? | | — | The latest day that can be chosen. |
isDateDisabled? | | — | Your own rule for days that can't be chosen. |
weekStartsOn? | | | First day of the week, Sunday = 0, or |
firstDayOfWeek? | | — | 1.x name for |
locale? | | | Locale for month and weekday names. |
success? | | — | Confirmation, such as "Username available". Replaces the helper; an error replaces it. |
status? | | | Validation state the control shows: a spinner while |
required? | | | Whether a value is required. |
disabledStyle? | | |
|
appearance? | | | Surface look passed to the control. |
size? | | | Control size passed to the control. |
shape? | | | Control shape passed to the control. |
labelPlacement? | | | Where the label sits. |
focusRing? | | | Focus indicator passed to the control. |
label | | — | Visible and spoken field label. |
value? | | — | Controlled local day. |
defaultValue? | | | Initial day. |
onValueChange? | | — | Reports an accepted local day after confirmation. |
engine? | | | Native OS picker or token-aware calendar. |
open? | | — | Controlled presentation. |
defaultOpen? | | | Initial presentation. |
onOpenChange? | | — | Reports opening, confirmation or dismissal. |
placeholder? | | | Empty trigger text. |
helper? | | — | Supporting instructions. |
error? | | — | Validation message. |
disabled? | | | Prevent opening and selection. |
motion? | | — | Custom engine motion; native owns its motion. |
haptics? | | | Trigger feedback. |
presentation? | | — | Auto uses a sheet on phones and an anchored popover on wider screens. |
closeOnSelect? | | | Close shortly after selecting a date. |
closeDelay? | | | Content delay before closing in milliseconds. |
shortcuts? | | | Enable default shortcuts or supply named local dates. |
format? | | — | Intl options or your own formatter. |
clearable? | | | Show an external clear action. |
messages? | | — | Shortcut and clear labels. |
className? | | — | Root classes. |
style? | | — | Native layout escape hatch. |
testID? | | — | Trigger ID. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Date picker settings
| Prop | Does | Default |
|---|---|---|
| haptics | Enables selection or press feedback | true |
| motion | Overrides the app's motion feel | App feel |
| presentation | auto, popover, sheet or native | auto | | clearable | Clear the date | false | | closeOnSelect | Close after picking | true | | closeDelay | Content delay before closing | 250ms | | shortcuts | Today, Tomorrow, Next week or custom dates | false | | format | Intl options or a formatting callback | Medium date | | weekStartsOn | Calendar week start | Monday |
engine="custom" without presentation keeps the 1.x Apply/Cancel draft. New presentations pick directly. The embedded Calendar uses surface="plain" caption={false}. Native runtime remains pending.
Composition and behavior
- A labelled field that opens the OS picker or a Calendar sheet with Cancel and Apply.
- engine chooses native or custom; open and onOpenChange control it.
- value and onValueChange hold the confirmed day.
Engine support
| Capability | Native iOS | Native Android | Custom iOS/Android |
|---|---|---|---|
| Requested locale | Yes | OS-owned / unsupported | Yes |
| Shared custom motion | OS-owned / unsupported | OS-owned / unsupported | Yes |
| Preset colours and shapes | OS-owned / unsupported | OS-owned / unsupported | Yes |
| Disabled-date predicate | OS-owned / unsupported | OS-owned / unsupported | Yes |
| Requested 12/24-hour display | OS-owned / unsupported | Yes | Yes |
| Minute intervals | OS-owned / unsupported | OS-owned / unsupported | Yes |
Native iOS is inline inside the sheet; Android uses an OS dialog. Native iOS follows locale/system hour settings. Custom minute intervals must divide 60. Acceptance always checks date constraints, but the native engine cannot visually disable arbitrary dates. Static adapter support does not establish native runtime compatibility.
Behavior and gestures
- Tap the field to open the native picker (the default) or a calendar sheet (custom engine).
- In the custom sheet, pick a day, then Apply to confirm or Cancel to discard your change.
- The field only updates after you confirm.
- Unsupported options for the native engine are reported in development, never silently ignored.
Accessibility
- The field reads its label and current value, such as "Start date: 3 Nov 2026", and reports expanded state.
- Apply is labelled with the field name, such as "Apply Start date".
- The native engine brings the platform's own accessibility.
- Helper and error text are read as the field's hint.
Motion
- Uses the
overlay,layoutandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The custom sheet uses the overlay role; the native picker uses system motion.
- Reduce Motion fades the sheet.
Performance
- The native engine costs nothing until opened; the custom one mounts its calendar on open.
Notes for AI
- Use engine="custom" when you need isDateDisabled; see the engine support table.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.