suiss/uim · Pattern

Date Picker

A date field that opens a drawer with day, month and year wheels ordered for the locale.

Date Picker is an open-source mobile pattern from suiss/uim: components composed into a flow for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Date Picker on iOS in light mode

DatePicker renders a field-style DrawerTrigger with a calendar icon and the selected date formatted with Intl.DateTimeFormat in the medium date style. The trigger sizes itself to its content rather than filling the width; pass className to change that. Pressing it opens a Drawer with three WheelPicker columns.

The column order follows the locale's short date format, falling back to month, day, year. Month names come from the locale, and the day column shrinks or grows with the chosen month and year, clamping the day when needed.

Installation

$ pnpm dlx @esuiss/uim@latest add date-picker

The CLI also adds what it builds on: Drawer, Icon, Text, Wheel Picker.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Drawer, Icon, Text, Wheel Picker.

  2. Copy the source into components/patterns/date-picker.tsx:

uniwind/components/patterns/date-picker.tsx
import { cn } from "cn"
import { CalendarBlankIcon } from "phosphor-react-native"
import * as React from "react"
import {
  Drawer,
  DrawerContent,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"
import {
  WheelPicker,
  WheelPickerColumn,
  WheelPickerItem,
  1. Update the import paths to match your project.

Usage

import { DatePicker } from "@/components/patterns/date-picker"
<DatePicker accessibilityLabel="Date" />

Use it uncontrolled with defaultValue, or controlled with value and onValueChange. The value is a Date or null; onValueChange fires on every wheel change, so there is no separate confirm step.

When no value is set the wheels start at today and the field shows placeholder. Limit the year column with fromYear and toYear.

Examples

With value

Starts with a preset date via defaultValue.

iOS
Date Picker (with value) on iOS in light mode

Locale

Uses tr-TR, which reorders the wheels and translates month names.

iOS
Date Picker (locale) on iOS in light mode

Year range

A date-of-birth field limited to 1940 through 2010.

iOS
Date Picker (year range) on iOS in light mode

With title

Adds a heading to the drawer with title.

iOS
Date Picker (with title) on iOS in light mode

With close button

Shows a close button in the drawer.

iOS
Date Picker (with close button) on iOS in light mode

With close label

Labels the close button Done with closeLabel.

iOS
Date Picker (with close label) on iOS in light mode

Disabled

A disabled field that cannot open the drawer.

iOS
Date Picker (disabled) on iOS in light mode

Invalid

Shows the error border and tint with invalid.

iOS
Date Picker (invalid) on iOS in light mode

Controlled

Holds the date in state and prints the selection below.

iOS
Date Picker (controlled) on iOS in light mode

Floating

Detaches the drawer from the screen edges.

iOS
Date Picker (floating) on iOS in light mode

API Reference

DatePicker

PropType
About
The selected date when controlled, or null.
Type
Datenull
Default
—
About
The initial date when uncontrolled.
Type
Datenull
Default
—
About
Called with the new Date on every wheel change.
Type
(value: Date | null) => void
Default
—
About
Text shown when no date is set. Defaults to Pick a date.
Type
string
Default
"Pick a date"
About
BCP 47 locale for formatting, month names and wheel order.
Type
string
Default
—
About
First year in the year wheel. Defaults to 100 years ago.
Type
number
Default
new Date().getFullYear() - 100
About
Last year in the year wheel. Defaults to 10 years ahead.
Type
number
Default
new Date().getFullYear() + 10
About
Heading shown at the top of the drawer.
Type
string
Default
—
About
Prevents opening and dims the field.
Type
boolean
Default
—
About
Insets the drawer from the screen edges.
Type
boolean
Default
—
About
Shows a close button in the drawer. Defaults to false.
Type
boolean
Default
false
About
Label of the close button.
Type
string
Default
—
About
Applies the error border and background.
Type
boolean
Default
—
About
Extra classes for the field, for example w-full to fill the width.
Type
string
Default
—
About
Label for the field, also used for the drawer when there is no title.
Type
string
Default
—
About
Links the field to a visible label.
Type
string
Default
—

Accessibility

  • The wheels are labelled Day, Month and Year.
  • Without a title, the drawer is labelled by accessibilityLabel or the placeholder.

Notes

  • The field uses bg-control, border-danger with a bg-danger tint when invalid, and bg-control-disabled when disabled; the tint is stronger in dark mode.
  • Without floating, the drawer's top corners are square.