Calendar
A month in an elevated card: a chosen-day circle that pulls across to the next pick, months that slide under the finger, today's dot, ranges with week bars, and hold-and-drag picking that turns months at the edges.
npx @swipeui/cli add calendarWhen to use it
- Showing a month on a screen and letting people pick a day, such as a booking, delivery or planner date.
- Picking a range inline (`mode="range"`), with blocked days, minimum and maximum dates.
- Planners that mark days with up to three coloured dots.
- A month that folds into the chosen week to save room (`collapsible`).
When not to use it
- A date field in a form. Use Date picker.
- A range with presets and Apply in a sheet. Use Date range picker.
- Choosing a day this week. Use Week strip.
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 calendar- Adds
components/swipeui/ui/calendar.tsx,components/swipeui/ui/calendar-format.ts,components/swipeui/ui/use-calendar-month.ts,components/swipeui/ui/use-calendar.tsand 14 shared helpers. - Installs react-native-gesture-handler, react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Calendar } from '@/components/swipeui/ui/calendar';
<Calendar value={date} onValueChange={setDate} />;The chosen day is written out under the card ("Thursday, November 12, 2026"). Pass caption={false} to leave it out.
Examples
A range with blocked nights. Tap the first and last days, or hold a day and drag; rest against a side edge to carry the range into the next month. A range never runs across a blocked day:
<Calendar
mode="range"
range={stay}
onRangeChange={setStay}
minDate={new Date()}
isDateDisabled={isBooked}
/>A planner with up to three dots per day, folding into the chosen week:
<Calendar
collapsible
markers={(date) => (hasMeeting(date) ? ['primary'] : undefined)}
onValueChange={setDay}
/>API reference
CalendarProps
| Prop | Type | Default | Description |
|---|---|---|---|
mode? | | |
|
value? | | — | The chosen day (controlled, single mode). |
defaultValue? | | | The day it starts with (uncontrolled, single mode). |
onValueChange? | | — | Reports a chosen day. |
range? | | — | The chosen range (controlled, range mode). In single mode, a range shown but not edited (1.x). |
defaultRange? | | | The range it starts with (uncontrolled, range mode). |
onRangeChange? | | — | Reports a range: the first day alone after one tap, then both. |
month? | | — | The visible month (controlled). |
defaultMonth? | | | The month it opens on. |
onMonthChange? | | — | Reports the visible month once a page settles. |
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. |
maxLength? | | | Range mode: the longest range in days, counting both ends. A drag or a second tap stops there, with a limit haptic. |
weekStartsOn? | | | First day of the week, Sunday = 0, or |
firstDayOfWeek? | | — | 1.x name for |
locale? | | | Locale for month and weekday names. |
markers? | | — | Dots under days, up to three: return their tones for a day. |
todayIndicator? | | | Today's marker: a small neutral dot under its number, or none. |
showToday? | | | A Today button in the header while another month is showing. |
outsideDays? | | | Days from the neighbouring months: dimmed (still pressable, without turning the month), hidden, or like the rest. |
selectedShape? | | | The selected day's shape: a circle, or the preset's control corners. |
surface? | | | An elevated card around the month, or no surface (inside a sheet or popover). |
caption? | | | The chosen day (or range) written out under the card. |
swipeMonths? | | | Swipe sideways to turn months; the month follows the finger. |
paintSelect? | | | ★ Hold a day and drag: the highlight follows the finger, and lifting picks (a range from the held day in range mode). |
holdDelay? | | | How long a finger rests on a day before dragging starts, in milliseconds (content timing). |
edgePaging? | | | ★ While holding, resting against the card's side edges turns the month. |
edgePageDelay? | | | The first turn comes as the finger reaches an edge; this is how long between further turns while it rests there, in milliseconds (content timing). |
collapsible? | | | ★ Swipe the card up to fold the month into the chosen week, and down to open it; a header button does the same. |
defaultCollapsed? | | | Start folded to one week (uncontrolled). |
disabled? | | | No turning, choosing or dragging. |
haptics? | | | Haptics: a switch, or per part ( |
motion? | | | Highlight, page and caption motion. |
messages? | | | Built-in strings and English name fallbacks. |
className? | | — | Classes on the card. |
style? | | — | Card style. |
testID? | | — | Root identifier; days append |
Composition and behavior
- The month sits in an elevated card (
surface="plain"inside a sheet). Every month has six rows, so the card never changes height. - The chosen day is a circle. Picking another day stretches it into a capsule that pulls away from the old day and lands on the new one: the leading edge on the toggle spring, the trailing edge on the slower overlay spring. Reduce Motion moves it at once.
- Days from the neighbouring months are dimmed and can be chosen without turning the month. Today has a small neutral dot under its number.
- Swipe sideways to turn months: the month follows your finger, the title slides with it, and a release turns the page. The ends stretch and answer with a warning tick. Vertical swipes still scroll the screen.
- ★ Hold a day and drag: a tinted highlight follows your finger, a tick for each day. Lifting picks the day, or sets the range from the day you held. Resting against a side edge turns the month at once, then every
edgePageDelay, without lifting. - ★
collapsiblefolds the month into the chosen week with a swipe up (a swipe down opens it) or the header chevron. In the web preview, use the chevron. - On the web: arrows move a day or a week, PageUp and PageDown a month, Home and End to the week's edges, and Enter chooses.
- Names come from
Intl, with English fallbacks inmessagesfor Hermes builds without locale data. The week starts on Monday on every platform, so the app and the web match;weekStartsOn="locale"follows the locale where the engine reports it (browsers do, Hermes doesn't).
Calendar settings
| Prop | Does | Default |
|---|---|---|
| mode | single or range | single |
| surface | card (elevated) or plain | card |
| caption | The chosen day or range written out under the card | true |
| selectedShape | circle or preset corners | circle |
| outsideDays | dim, hidden or normal | dim |
| todayIndicator | dot or none | dot |
| showToday | A Today button while another month shows | true |
| markers | Up to three dot tones per day | none |
| swipeMonths | Swipe to turn months | true |
| paintSelect / holdDelay | ★ Hold a day and drag to pick (ms to hold) | true, 350 |
| edgePaging / edgePageDelay | ★ Turn months at the side edges while holding (ms between turns) | true, 1000 |
| collapsible / defaultCollapsed | ★ Fold the month into the chosen week | false |
| weekStartsOn | First day of the week (Sunday = 0), or locale | 1 (Monday) |
| minDate / maxDate / isDateDisabled | Days that can't be chosen | none |
| maxLength | Longest range in days (range mode); drags and taps stop there | unlimited |
| haptics | All, or { select, detent, limit } | on |
| messages | Built-in strings and English name fallbacks | English |
| motion | A local motion feel or override | the app's feel |
Behavior and gestures
- Tap a day to choose it: the circle stretches away from the old day and lands on the new one. Days from the neighbouring months are dimmed and can be chosen without turning the month.
- Swipe sideways to turn months: the month follows the finger and the title slides with it; the previous and next buttons do the same. Turning stops at your minimum and maximum dates with a warning tick.
- Range mode: tap the first day, then the last; or hold a day and drag. A tinted highlight follows the finger, resting against a side edge turns the month without lifting (then every second), a range stops before a day that can't be chosen, and lifting sets the range.
- Single mode: hold a day and slide; lifting chooses the day under the finger.
- The chosen day ("Sunday, November 8, 2026") or range ("From Nov 9 to Nov 14, 2026, 6 days") is written out under the card.
- With `collapsible`, swipe up to fold the month into the chosen week and down to open it, or use the header chevron.
- On the web: arrows move a day or a week, PageUp and PageDown a month, Home and End to the week's edges, and Enter chooses.
Accessibility
- Each day reads its full date, plus "today", "outside this month" or "unavailable", and reports selected; range days say Range start, Range end or In selected range.
- Month changes and finished ranges are announced; the caption is a polite live region.
- Previous month, Next month, Today and Show week are named buttons, so swiping, dragging and folding are all optional.
- At large accessibility text sizes the month becomes a list of full-width day rows.
Motion
- Uses the
select,toggle,overlay,morph,layoutandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The chosen-day circle's leading edge springs on the toggle role and its trailing edge on the slower overlay role, so it stretches into a capsule and lands.
- Months and the title turn on the select spring and follow the finger while dragging; the ends stretch.
- Folding to a week springs on the layout role; the caption rises in on morph.
- Reduce Motion: the circle and months move at once, the caption fades, and haptics stay.
Performance
- Only the visible month and its two neighbours render. Drags report one day at a time from the UI thread.
- All maths uses local calendar fields, so daylight-saving days never shift a date; today refreshes at midnight and when the app returns.
Notes for AI
- Single mode uses value/onValueChange; range mode uses range/onRangeChange. In single mode a `range` prop is drawn but not edited (1.x).
- The week starts on Monday on every platform; pass weekStartsOn (Sunday = 0) or `locale` to follow the locale's week where the engine reports it. `firstDayOfWeek` still works.
- Pass `surface="plain" caption={false}` inside a sheet or popover.
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.